!function(C,e,n,T){"use strict";e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),C.fn.rating=function(m){var f,v=C(this),p=v.selector||"",b=(new Date).getTime(),h=[],y=m,x="string"==typeof y,R=[].slice.call(arguments,1);return v.each(function(){var e,i,a=C.isPlainObject(m)?C.extend(!0,{},C.fn.rating.settings,m):C.extend({},C.fn.rating.settings),n=a.namespace,o=a.className,t=a.metadata,r=a.selector,s=(a.error,"."+n),l="module-"+n,c=this,u=C(this).data(l),d=C(this),g=d.find(r.icon);i={initialize:function(){i.verbose("Initializing rating module",a),0===g.length&&i.setup.layout(),a.interactive?i.enable():i.disable(),i.set.initialLoad(),i.set.rating(i.get.initialRating()),i.remove.initialLoad(),i.instantiate()},instantiate:function(){i.verbose("Instantiating module",a),u=i,d.data(l,i)},destroy:function(){i.verbose("Destroying previous instance",u),i.remove.events(),d.removeData(l)},refresh:function(){g=d.find(r.icon)},setup:{layout:function(){var e=i.get.maxRating(),n=C.fn.rating.settings.templates.icon(e);i.debug("Generating icon html dynamically"),d.html(n),i.refresh()}},event:{mouseenter:function(){var e=C(this);e.nextAll().removeClass(o.selected),d.addClass(o.selected),e.addClass(o.selected).prevAll().addClass(o.selected)},mouseleave:function(){d.removeClass(o.selected),g.removeClass(o.selected)},click:function(){var e=C(this),n=i.get.rating(),t=g.index(e)+1;("auto"==a.clearable?1===g.length:a.clearable)&&n==t?i.clearRating():i.set.rating(t)}},clearRating:function(){i.debug("Clearing current rating"),i.set.rating(0)},bind:{events:function(){i.verbose("Binding events"),d.on("mouseenter"+s,r.icon,i.event.mouseenter).on("mouseleave"+s,r.icon,i.event.mouseleave).on("click"+s,r.icon,i.event.click)}},remove:{events:function(){i.verbose("Removing events"),d.off(s)},initialLoad:function(){e=!1}},enable:function(){i.debug("Setting rating to interactive mode"),i.bind.events(),d.removeClass(o.disabled)},disable:function(){i.debug("Setting rating to read-only mode"),i.remove.events(),d.addClass(o.disabled)},is:{initialLoad:function(){return e}},get:{initialRating:function(){return d.data(t.rating)!==T?(d.removeData(t.rating),d.data(t.rating)):a.initialRating},maxRating:function(){return d.data(t.maxRating)!==T?(d.removeData(t.maxRating),d.data(t.maxRating)):a.maxRating},rating:function(){var e=g.filter("."+o.active).length;return i.verbose("Current rating retrieved",e),e}},set:{rating:function(e){var n=0<=e-1?e-1:0,t=g.eq(n);d.removeClass(o.selected),g.removeClass(o.selected).removeClass(o.active),0',n++;return t}}}}(jQuery,window,document); var current_fs, next_fs, previous_fs; var left, opacity, scale; var animating, percentAnimate; function aysAnimateStep(animation, current_fs, next_fs){ if(typeof next_fs!=="undefined"){ switch(animation){ case "lswing": current_fs.parents('.ays-questions-container').css({ perspective: '800px', }); current_fs.addClass('swing-out-right-bck'); current_fs.css({ 'pointer-events': 'none' }); next_fs.css({ 'pointer-events': 'none' }); setTimeout(function(){ current_fs.css({ 'position': 'absolute', }); next_fs.css('display', 'flex'); next_fs.addClass('swing-in-left-fwd'); },400); setTimeout(function(){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'position': 'static' }); next_fs.css({ 'position':'relative', 'pointer-events': 'auto' }); current_fs.removeClass('swing-out-right-bck'); next_fs.removeClass('swing-in-left-fwd'); animating=false; },1000); break; case "rswing": current_fs.parents('.ays-questions-container').css({ perspective: '800px', }); current_fs.addClass('swing-out-left-bck'); current_fs.css({ 'pointer-events': 'none' }); next_fs.css({ 'pointer-events': 'none' }); setTimeout(function(){ current_fs.css({ 'position': 'absolute', }); next_fs.css('display', 'flex'); next_fs.addClass('swing-in-right-fwd'); },400); setTimeout(function(){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'position': 'static' }); next_fs.css({ 'position':'relative', 'pointer-events': 'auto' }); current_fs.removeClass('swing-out-left-bck'); next_fs.removeClass('swing-in-right-fwd'); animating=false; },1000); break; case "shake": next_fs.css('transform', 'scale(1)'); current_fs.animate({opacity: 0}, { step: function (now, mx){ scale=1 - (1 - now) * 0.2; left=(now * 50) + "%"; opacity=1 - now; current_fs.css({ 'transform': 'scale(' + scale + ')', 'position': 'absolute', 'top':0, 'opacity': 1, 'pointer-events': 'none' }); next_fs.css({ 'left': left, 'opacity': opacity, 'display':'flex', 'position':'relative', 'pointer-events': 'none' }); }, duration: 800, complete: function (){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'opacity': 1, 'position': 'static' }); next_fs.css({ 'display':'flex', 'position':'relative', 'transform':'scale(1)', 'opacity': 1, 'pointer-events': 'auto' }); animating=false; }, easing: 'easeInOutBack' }); break; case "fade": current_fs.animate({opacity: 0}, { step: function (now, mx){ opacity=1 - now; current_fs.css({ 'position': 'absolute', 'pointer-events': 'none' }); next_fs.css({ 'opacity': opacity, 'position':'relative', 'display':'flex', 'pointer-events': 'none' }); }, duration: 500, complete: function (){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'position': 'static' }); next_fs.css({ 'display':'flex', 'position':'relative', 'transform':'scale(1)', 'opacity': 1, 'pointer-events': 'auto' }); animating=false; }}); break; default: current_fs.animate({}, { step: function (now, mx){ current_fs.css({ 'pointer-events': 'none' }); next_fs.css({ 'position':'relative', 'pointer-events': 'none' }); }, duration: 0, complete: function (){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto' }); next_fs.css({ 'display':'flex', 'position':'relative', 'transform':'scale(1)', 'pointer-events': 'auto' }); animating=false; }}); break; }}else{ switch(animation){ case "lswing": current_fs.parents('.ays-questions-container').css({ perspective: '800px', }); current_fs.addClass('swing-out-right-bck'); current_fs.css({ 'pointer-events': 'none' }); setTimeout(function(){ current_fs.css({ 'position': 'absolute', }); },400); setTimeout(function(){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'position': 'static' }); current_fs.removeClass('swing-out-right-bck'); animating=false; },1000); break; case "rswing": current_fs.parents('.ays-questions-container').css({ perspective: '800px', }); current_fs.addClass('swing-out-left-bck'); current_fs.css({ 'pointer-events': 'none' }); setTimeout(function(){ current_fs.css({ 'position': 'absolute', }); },400); setTimeout(function(){ current_fs.hide(); current_fs.css({ 'pointer-events': 'auto', 'position': 'static' }); current_fs.removeClass('swing-out-left-bck'); animating=false; },1000); case "shake": current_fs.animate({opacity: 0}, { step: function (now, mx){ scale=1 - (1 - now) * 0.2; left=(now * 50) + "%"; opacity=1 - now; current_fs.css({ 'transform': 'scale(' + scale + ')', }); }, duration: 800, complete: function (){ current_fs.hide(); animating=false; }, easing: 'easeInOutBack' }); break; case "fade": current_fs.animate({opacity: 0}, { step: function (now, mx){ opacity=1 - now; }, duration: 500, complete: function (){ current_fs.hide(); animating=false; }, easing: 'easeInOutBack' }); break; default: current_fs.animate({}, { step: function (now, mx){ }, duration: 0, complete: function (){ current_fs.hide(); animating=false; }}); break; }} } function GetFullDateTime(){ var now=new Date(); return [[now.getFullYear(), AddZero(now.getMonth() + 1), AddZero(now.getDate())].join("-"), [AddZero(now.getHours()), AddZero(now.getMinutes()), AddZero(now.getSeconds())].join(":")].join(" "); } function AddZero(num){ return (num >=0&&num < 10) ? "0" + num:num + ""; } function aysEscapeHtml(text){ var map={ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return text.replace(/[&<>\"']/g, function(m){ return map[m]; }); } function audioVolumeIn(q){ if(q.volume){ var InT=0; var setVolume=1; var speed=0.05; q.volume=InT; var eAudio=setInterval(function(){ InT +=speed; q.volume=InT.toFixed(1); if(InT.toFixed(1) >=setVolume){ q.volume=1; clearInterval(eAudio); };},50); };}; function audioVolumeOut(q){ if(q.volume){ var InT=1; var setVolume=0; var speed=0.05; q.volume=InT; var fAudio=setInterval(function(){ InT -=speed; q.volume=InT.toFixed(1); if(InT.toFixed(1) <=setVolume){ clearInterval(fAudio); };},50); };}; function isPlaying(audelem){ return !audelem.paused; } function resetPlaying(audelems){ for(var i=0; i < audelems.length; i++){ audelems[i].pause(); audelems[i].currentTime=0; }} function validatePhoneNumber(input){ var phoneno=/^[+ 0-9-]+$/; if(input.value.match(phoneno)){ return true; }else{ return false; }} function checkQuizPassword(e, myOptions, isAlert){ var passwordQuizInput=jQuery(e.target).parents('.step').find("input.ays_quiz_password"); if(passwordQuizInput.length > 0){ var passwordQuiz=passwordQuizInput.val(); if(myOptions.enable_password&&myOptions.enable_password=='on'){ if(myOptions.generate_password&&myOptions.generate_password=='generated_password'){ var generated_passwords=myOptions.generated_passwords; var active_passwords=generated_passwords.active_passwords; var flag=false; for (var index in active_passwords){ if(active_passwords[index]==passwordQuiz){ flag=true; break; }} if(flag===false){ if(isAlert){ alert(quizLangObj.passwordIsWrong); } return false; }}else{ if(myOptions.password_quiz&&myOptions.password_quiz!==passwordQuiz){ if(isAlert){ alert(quizLangObj.passwordIsWrong); } return false; }} }} return true; } function ays_countdown_datetime(sec, showMessage){ var distance=sec*1000; var x_int; x_int=setInterval(function(){ var days=Math.floor(distance / (1000 * 60 * 60 * 24)); var hours=Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes=Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds=Math.floor((distance % (1000 * 60)) / 1000); var text=""; if(days > 0){ text +=days + " "; if(days==1){ text +=quizLangObj.day + " "; }else{ text +=quizLangObj.days + " "; }} if(hours > 0){ text +=hours + " "; if(hours==1){ text +=quizLangObj.hour + " "; }else{ text +=quizLangObj.hours + " "; }} if(minutes > 0){ text +=minutes + " "; if(minutes==1){ text +=quizLangObj.minute + " "; }else{ text +=quizLangObj.minutes + " "; }} text +=seconds + " " + quizLangObj.seconds; document.getElementById("show_timer_countdown").innerHTML=text; if(distance > 0){ distance -=1000; } if(distance <=0){ clearInterval(x_int); if(showMessage){ document.getElementById("show_timer_countdown").innerHTML=quizLangObj.expiredMessage; }else{ document.getElementById("show_timer_countdown").innerHTML=''; }} if(distance==0){ location.reload(); }}, 1000); }; (function ($){ 'use strict'; $.fn.serializeFormJSON=function (){ var o={}, a=this.serializeArray(); $.each(a, function (){ if(o[this.name]){ if(!o[this.name].push){ o[this.name]=[o[this.name]]; } o[this.name].push(this.value||''); }else{ o[this.name]=this.value||''; }}); return o; }; $(document).ready(function (){ var current_fs, next_fs, previous_fs; var left, opacity, scale; var animating; var form, ays_quiz_container, ays_quiz_container_id; if(!$.fn.goTo){ $.fn.goTo=function(){ $('html, body').animate({ scrollTop: $(this).offset().top - 100 + 'px' }, 'slow'); return this; }} $.fn.aysModal=function(action){ var $this=$(this); switch(action){ case 'hide': $(this).find('.ays-modal-content').css('animation-name', 'zoomOut'); setTimeout(function(){ $(document.body).removeClass('modal-open'); $(document).find('.ays-modal-backdrop').remove(); $this.hide(); }, 250); break; case 'show': default: $this.show(); $(this).find('.ays-modal-content').css('animation-name', 'zoomIn'); $(document).find('.modal-backdrop').remove(); $(document.body).append('
'); $(document.body).addClass('modal-open'); break; }} if(!String.prototype.trim){ (function(){ String.prototype.trim=function(){ return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); };})(); } $(document).find(".ays-quiz-container .information_form").each(function(e){ var $this=$(this); var cont=$(document).find(".ays-quiz-container"); var thisCont=$this.parents('.ays-quiz-container'); var quizId=thisCont.find('input[name="ays_quiz_id"]').val(); var myOptions=JSON.parse(window.atob(window.aysQuizOptions[quizId])); if(myOptions.autofill_user_data&&myOptions.autofill_user_data=="on"){ var userData={}; userData.action='ays_get_user_information'; $.ajax({ url: quiz_maker_ajax_public.ajax_url, method: 'post', dataType: 'json', data: userData, success: function (response){ if(response!==null){ $this.find("input[name='ays_user_name']").val(response.data.display_name); $this.find("input[name='ays_user_email']").val(response.data.user_email); }} }); }}); $(document).find('input.ays_finish').on('click', function (e){ e.preventDefault(); ays_quiz_container_id=$(this).parents(".ays-quiz-container").attr("id"); ays_quiz_container=$('#'+ays_quiz_container_id); if($(document).scrollTop() >=$(this).parents('.ays-questions-container').offset().top){ ays_quiz_container.goTo(); } if(ays_quiz_container.find('.ays_music_sound').length!==0){ ays_quiz_container.find('.ays_music_sound').fadeOut(); setTimeout(function(){ audioVolumeOut(ays_quiz_container.find('.ays_quiz_music').get(0)); },4000); setTimeout(function(){ ays_quiz_container.find('.ays_quiz_music').get(0).pause(); },6000); } if(ays_quiz_container.find('audio').length > 0){ ays_quiz_container.find('audio').each(function(e, el){ el.pause(); }); } if(ays_quiz_container.find('video').length > 0){ ays_quiz_container.find('video').each(function(e, el){ el.pause(); }); } ays_quiz_container.find('.ays-live-bar-wrap').addClass('bounceOut'); setTimeout(function (){ ays_quiz_container.find('.ays-live-bar-wrap').css('display','none'); },300); var quizId=ays_quiz_container.find('input[name="ays_quiz_id"]').val(); var myOptions=JSON.parse(window.atob(window.aysQuizOptions[quizId])); var quizOptionsName='quizOptions_'+quizId; var myQuizOptions=[]; if(typeof window[quizOptionsName]!=='undefined'){ for(var i in window[quizOptionsName]){ myQuizOptions[i]=(JSON.parse(window.atob(window[quizOptionsName][i]))); }} var emailValivatePattern=/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/; if(!($(this).hasClass('start_button'))){ if($(this).parents('.step').find('input[required]').length!==0){ var empty_inputs=0; var required_inputs=$(this).parents('.step').find('input[required]'); $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border'); $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border'); for (var i=0; i < required_inputs.length; i++){ switch(required_inputs.eq(i).attr('type')){ case "checkbox": { if(required_inputs.eq(i).prop('checked')===false){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } case "email": { if(!(emailValivatePattern.test(required_inputs.eq(i).val()))){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } case "tel": { if(!validatePhoneNumber(required_inputs.eq(i).get(0))){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } default:{ if(required_inputs.eq(i).val()==='' && required_inputs.eq(i).attr('type')!=='hidden'){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; }} } var empty_inputs2=0; var phoneInput=$(this).parents('.step').find('input[name="ays_user_phone"]'); var emailInput=$(this).parents('.step').find('input[name="ays_user_email"]'); var selectAttr=$(this).parents('.step').find('select.ays_quiz_form_input[required]'); if(phoneInput.val()!=''){ phoneInput.removeClass('ays_red_border'); phoneInput.removeClass('ays_green_border'); if(!validatePhoneNumber(phoneInput.get(0))){ if(phoneInput.attr('type')!=='hidden'){ phoneInput.addClass('ays_red_border'); phoneInput.addClass('shake'); empty_inputs2++; }}else{ phoneInput.addClass('ays_green_border'); }} if(selectAttr.val()==''){ selectAttr.removeClass('ays_red_border'); selectAttr.removeClass('ays_green_border'); selectAttr.addClass('ays_red_border'); selectAttr.addClass('shake'); empty_inputs++; }else{ selectAttr.removeClass('ays_red_border'); } var errorFields=$(this).parents('.step').find('.ays_red_border'); if(empty_inputs2!==0||empty_inputs!==0){ setTimeout(function(){ errorFields.each(function(){ $(this).removeClass('shake'); }); }, 500); setTimeout(function(){ required_inputs.each(function(){ $(this).removeClass('shake'); }); }, 500); return false; }}else{ if($(this).parents('.step').find('.information_form').length!==0){ var empty_inputs=0; var phoneInput=$(this).parents('.step').find('input[name="ays_user_phone"]'); var emailInput=$(this).parents('.step').find('input[name="ays_user_email"]'); var emailInputs=$(this).parents('.step').find('input[type="email"]'); if(phoneInput.val()!=''){ phoneInput.removeClass('ays_red_border'); phoneInput.removeClass('ays_green_border'); if(!validatePhoneNumber(phoneInput.get(0))){ if(phoneInput.attr('type')!=='hidden'){ phoneInput.addClass('ays_red_border'); phoneInput.addClass('shake'); empty_inputs++; }}else{ phoneInput.addClass('ays_green_border'); }} if(emailInput.val()!=''){ emailInput.removeClass('ays_red_border'); emailInput.removeClass('ays_green_border'); if(!(emailValivatePattern.test(emailInput.val()))){ if(emailInput.attr('type')!=='hidden'){ emailInput.addClass('ays_red_border'); emailInput.addClass('shake'); empty_inputs++; }}else{ emailInput.addClass('ays_green_border'); }} emailInputs.each(function(){ var thisEmailInput=$(this); if(thisEmailInput.val()!=''){ thisEmailInput.removeClass('ays_red_border'); thisEmailInput.removeClass('ays_green_border'); if(!(emailValivatePattern.test(thisEmailInput.val()))){ thisEmailInput.addClass('ays_red_border'); thisEmailInput.addClass('shake'); empty_inputs++; }else{ thisEmailInput.addClass('ays_green_border'); }} }); var errorFields=$(this).parents('.step').find('.ays_red_border'); if(empty_inputs!==0){ setTimeout(function(){ errorFields.each(function(){ $(this).removeClass('shake'); }); }, 500); return false; }} }} var next_sibilings_count=$(this).parents('form').find('.ays_question_count_per_page').val(); $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); $(e.target).parents().eq(3).find('div.ays-quiz-timer').slideUp(500); if($(e.target).parents().eq(3).find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){ $(e.target).parents().eq(3).find('div.ays-quiz-timer').parent().slideUp(500); } next_fs=$(this).parents('.step').next(); current_fs=$(this).parents('.step'); next_fs.addClass('active-step'); current_fs.removeClass('active-step'); form=ays_quiz_container.find('form'); var textAnswers=form.find('div.ays-text-field textarea.ays-text-input'); for(var i=0; i < textAnswers.length; i++){ var userAnsweredText=textAnswers.eq(i).val().trim(); var questionId=textAnswers.eq(i).parents('.step').data('questionId'); var trueAnswered=false; var thisQuestionCorrectAnswer=myQuizOptions[questionId].question_answer=='' ? "":myQuizOptions[questionId].question_answer; var thisQuestionAnswer=thisQuestionCorrectAnswer.toLowerCase(); thisQuestionAnswer=thisQuestionAnswer.split('%%%'); for(var i_answer=0; i_answer < thisQuestionAnswer.length; i_answer++){ if(userAnsweredText.toLowerCase()==thisQuestionAnswer[i_answer].trim()){ trueAnswered=true; break; }} if(trueAnswered){ textAnswers.eq(i).next().val(1); }else{ textAnswers.eq(i).next().val(0); if(thisQuestionCorrectAnswer==''){ textAnswers.eq(i).attr('chishtpatasxan', '-'); }else{ textAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer); }} textAnswers.eq(i).removeAttr('disabled'); } var numberAnswers=form.find('div.ays-text-field input[type="number"].ays-text-input'); for(var i=0; i < numberAnswers.length; i++){ var userAnsweredText=numberAnswers.eq(i).val().trim(); var questionId=numberAnswers.eq(i).parents('.step').data('questionId'); if(userAnsweredText.toLowerCase()===myQuizOptions[questionId].question_answer.toLowerCase()){ numberAnswers.eq(i).next().val(1); }else{ numberAnswers.eq(i).next().val(0); numberAnswers.eq(i).attr('chishtpatasxan', myQuizOptions[questionId].question_answer); } numberAnswers.eq(i).removeAttr('disabled') } var shortTextAnswers=form.find('div.ays-text-field input[type="text"].ays-text-input'); for(var i=0; i < shortTextAnswers.length; i++){ var userAnsweredText=shortTextAnswers.eq(i).val().trim(); var questionId=shortTextAnswers.eq(i).parents('.step').data('questionId'); var trueAnswered=false; var thisQuestionCorrectAnswer=myQuizOptions[questionId].question_answer=='' ? "":myQuizOptions[questionId].question_answer; var thisQuestionAnswer=thisQuestionCorrectAnswer.toLowerCase(); thisQuestionAnswer=thisQuestionAnswer.split('%%%'); for(var i_answer=0; i_answer < thisQuestionAnswer.length; i_answer++){ if(userAnsweredText.toLowerCase()==thisQuestionAnswer[i_answer].trim()){ trueAnswered=true; break; }} if(trueAnswered){ shortTextAnswers.eq(i).next().val(1); }else{ shortTextAnswers.eq(i).next().val(0); if(thisQuestionCorrectAnswer==''){ shortTextAnswers.eq(i).attr('chishtpatasxan', '-'); }else{ shortTextAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer); }} shortTextAnswers.eq(i).removeAttr('disabled') } var dateAnswers=form.find('div.ays-text-field input[type="date"].ays-text-input'); for(var i=0; i < dateAnswers.length; i++){ var userAnsweredText=dateAnswers.eq(i).val(); var questionId=dateAnswers.eq(i).parents('.step').data('questionId'); var thisQuestionCorrectAnswer=myQuizOptions[questionId].question_answer=='' ? "":myQuizOptions[questionId].question_answer; var trueAnswered=false; var correctDate=new Date(thisQuestionCorrectAnswer), correctDateYear=correctDate.getFullYear(), correctDateMonth=correctDate.getMonth(), correctDateDay=correctDate.getDate(); var userDate=new Date(userAnsweredText), userDateYear=userDate.getFullYear(), userDateMonth=userDate.getMonth(), userDateDay=userDate.getDate(); if(correctDateYear==userDateYear&&correctDateMonth==userDateMonth&&correctDateDay==userDateDay){ trueAnswered=true; } if(trueAnswered){ dateAnswers.eq(i).next().val(1); }else{ dateAnswers.eq(i).next().val(0); if(thisQuestionCorrectAnswer==''){ dateAnswers.eq(i).attr('chishtpatasxan', '-'); }else{ dateAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer); }} dateAnswers.eq(i).removeAttr('disabled') } var data=form.serializeFormJSON(); var questionsIds=data.ays_quiz_questions.split(','); for(var i=0; i < questionsIds.length; i++){ if(! data['ays_questions[ays-question-'+questionsIds[i]+']']){ data['ays_questions[ays-question-'+questionsIds[i]+']']=""; }} data.action='ays_finish_quiz'; data.end_date=GetFullDateTime(); var aysQuizLoader=form.find('div[data-role="loader"]'); aysQuizLoader.addClass(aysQuizLoader.data('class')); aysQuizLoader.removeClass('ays-loader'); var animationOptions={ scale: scale, left: left, opacity: opacity, animating: animating } setTimeout(function (){ sendQuizData(data, form, myOptions, animationOptions, $(e.target)); },2000); if(parseInt(next_sibilings_count) > 0&&($(this).parents('.step').attr('data-question-id')||$(this).parents('.step').next().attr('data-question-id'))){ current_fs=$(this).parents('form').find('div[data-question-id]'); }}); $(document).find('.ays_next.start_button').on('click',function(e){ var $this=$(this); var thisCont=$this.parents('.ays-quiz-container'); var quizId=thisCont.find('input[name="ays_quiz_id"]').val(); var myOptions=JSON.parse(window.atob(window.aysQuizOptions[quizId])); var checkQuizGeneratedPassword=checkQuizPassword(e, myOptions, false); if(checkQuizGeneratedPassword){ if(myOptions.enable_password&&myOptions.enable_password=='on'){ if(myOptions.generate_password&&myOptions.generate_password=='generated_password'){ var userGeneratedPasswordVal=$this.parents('.ays-quiz-container').find('.ays_quiz_password').val(); var userData={}; userData.action='ays_generated_used_passwords'; userData.userGeneratedPassword=userGeneratedPasswordVal; userData.quizId=quizId; $.ajax({ url: quiz_maker_ajax_public.ajax_url, method: 'post', dataType: 'json', data: userData, success: function (response){ if(response.status){ }} }); }} }}); }); function sendQuizData(data, form, myOptions, options, element){ if(typeof sendQuizData.counter=='undefined'){ sendQuizData.counter=0; } if(window.navigator.onLine){ sendQuizData.counter++; $.ajax({ url: window.quiz_maker_ajax_public.ajax_url, method: 'post', dataType: 'json', data: data, success: function(response){ if(response.status===true){ doQuizResult(response, form, myOptions); }else{ if(sendQuizData.counter >=5){ swal.fire({ type: 'error', html: quizLangObj.sorry + ".
" + quizLangObj.unableStoreData + "." }); goQuizFinishPage(form, options, element, myOptions); }else{ if(window.navigator.onLine){ setTimeout(function(){ sendQuizData(data, form, myOptions, options, element); },3000); }else{ sendQuizData(data, form, myOptions, options, element); }} }}, error: function(jqXHR, textStatus, errorThrown){ if(sendQuizData.counter >=5){ swal.fire({ type: 'error', html: quizLangObj.sorry + ".
" + quizLangObj.unableStoreData + "." }); goQuizFinishPage(form, options, element, myOptions); }else{ setTimeout(function(){ sendQuizData(data, form, myOptions, options, element); },3000); }} }); }else{ swal.fire({ type: 'warning', html: quizLangObj.connectionLost + ".
" + quizLangObj.checkConnection + "." }); sendQuizData.counter=0; goQuizFinishPage(form, options, element, myOptions); }} function goQuizFinishPage(form, options, element, myOptions){ var currentFS=form.find('.step.active-step'); var next_sibilings_count=form.find('.ays_question_count_per_page').val(); if(parseInt(next_sibilings_count) > 0 && (element.parents('.step').attr('data-question-id') || element.parents('.step').next().attr('data-question-id'))){ currentFS=form.find('div[data-question-id]'); } currentFS.prev().css('display', 'flex'); currentFS.animate({opacity: 0}, { step: function(now, mx){ options.scale=1 - (1 - now) * 0.2; options.left=(now * 50)+"%"; options.opacity=1 - now; currentFS.css({ 'transform': 'scale('+options.scale+')', 'position': '', 'pointer-events': 'none' }); currentFS.prev().css({ 'left': options.left, 'opacity': options.opacity, 'pointer-events': 'none' }); }, duration: 800, complete: function(){ currentFS.hide(); currentFS.css({ 'opacity': '1', 'pointer-events': 'auto', }); currentFS.prev().css({ 'transform': 'scale(1)', 'position': 'relative', 'opacity': '1', 'pointer-events': 'auto' }); options.animating=false; }, easing: 'easeInOutBack' }); if(myOptions.enable_correction=='on'){ if(currentFS.prev().find('input:checked').length > 0){ currentFS.prev().find('.ays-field input').attr('disabled', 'disabled'); currentFS.prev().find('.ays-field input').on('click', function(){ return false; }); currentFS.prev().find('.ays-field input').on('change', function(){ return false; }); } if(currentFS.prev().find('option:checked').length > 0){ currentFS.prev().find('.ays-field select').attr('disabled', 'disabled'); currentFS.prev().find('.ays-field select').on('click', function(){ return false; }); currentFS.prev().find('.ays-field select').on('change', function(){ return false; }); } if(currentFS.prev().find('textarea').length > 0){ if(currentFS.prev().find('textarea').val()!==''){ currentFS.prev().find('.ays-field textarea').attr('disabled', 'disabled'); currentFS.prev().find('.ays-field textarea').on('click', function(){ return false; }); currentFS.prev().find('.ays-field textarea').on('change', function(){ return false; }); }} }} function doQuizResult(response, form, myOptions){ var hideQuizBGImage=form.parents('.ays-quiz-container').data('hideBgImage'); var QuizBGGragient=form.parents('.ays-quiz-container').data('bgGradient'); if(hideQuizBGImage){ form.parents('.ays-quiz-container').css('background-image', 'none'); if(typeof QuizBGGragient!='undefined'){ form.parents('.ays-quiz-container').css('background-image', QuizBGGragient); }} form.find('div.ays_message').css('display', 'none'); form.find('.ays_average').css({'display': 'block'}); var quizScore=''; switch(response.displayScore){ case 'by_percentage': quizScore=parseInt(response.score); break; case 'by_correctness': quizScore=response.score.split('/'); break; case 'by_points': quizScore=response.score.split('/'); break; default: quizScore=parseInt(response.score); } if(response.hide_result){ form.find('div.ays_message').html(response.text); }else{ if(response.showIntervalMessage){ form.find('div.ays_message').html(response.intervalMessage + response.finishText); if(response.product){ var $wooBlock=$("
"); var $wooInBlock=$("
"); var $wooImage=$('
WooCommerce Product
'); var $wooName=$('

'+response.product.name+'

'); var $wooCartLink=$(response.product.link); if(response.product.image){ $wooBlock.append($wooImage); } $wooInBlock.append($wooName); $wooInBlock.append($wooCartLink); $wooBlock.append($wooInBlock); form.find('div.ays_message').after($wooBlock); if(form.parents('.ays-quiz-container').width() < 420){ form.find('.ays-woo-block').css('flex-wrap', 'wrap'); if(response.product.image){ form.find('.ays-woo-product-block').css('padding-top', '20px'); }} }}else{ form.find('div.ays_message').html(response.finishText); } form.find('p.ays_score').removeClass('ays_score_display_none'); form.find('p.ays_score').html(form.find('p.ays_score').text()+' ' + response.score + ''); } form.find('div.ays_message').fadeIn(500); setTimeout(function (){ form.find('p.ays_score').addClass('tada'); }, 500); var numberOfPercent=0; var percentAnimate=setInterval(function(){ if(typeof quizScore=='number'){ form.find('.ays-progress-value').text(numberOfPercent + "%"); if(numberOfPercent==quizScore){ clearInterval(percentAnimate); } numberOfPercent++; }else{ var total=quizScore[1]; var count=quizScore[0]; total=parseFloat(total.trim()); count=parseFloat(count.trim()); form.find('.ays-progress-value').text(numberOfPercent + " / " + total); if(numberOfPercent >=count){ form.find('.ays-progress-value').text(count + " / " + total); clearInterval(percentAnimate); } numberOfPercent++; }},20); var score=quizScore; if(response.displayScore=='by_correctness'||response.displayScore=='by_points'){ var total=parseInt(quizScore[1].trim()); var count=parseInt(quizScore[0].trim()); score=(count / total) * 100; } if(response.scoreMessage){ form.find('div.ays_score_message').html(response.scoreMessage); } if(score > 0){ form.find('.ays-progress-bar').css('padding-right', '7px'); var progressBarStyle=myOptions.progress_bar_style ? myOptions.progress_bar_style:'first'; if(progressBarStyle=='first'||progressBarStyle=='second'){ form.find('.ays-progress-value').css('width', 0); form.find('.ays-progress-value').css('transition', 'width ' + score*25 + 'ms linear'); setTimeout(function(){ form.find('.ays-progress-value').css('width', score+'%'); }, 1); } form.find('.ays-progress-bar').css('transition', 'width ' + score*25 + 'ms linear'); setTimeout(function(){ form.find('.ays-progress-bar').css('width', score+'%'); }, 1); } form.append($("
")); var formResults=form.find('.ays_quiz_results'); if(form.hasClass('enable_questions_result')){ var questions=form.find('div[data-question-id]'); var showOnlyWrongAnswer=(myOptions.show_only_wrong_answer&&myOptions.show_only_wrong_answer=="on") ? true:false; if(myOptions.enable_correction&&myOptions.enable_correction!='on'){ showOnlyWrongAnswer=false; } for (var z=0; z < questions.length; z++){ if(questions.eq(z).hasClass('not_influence_to_score')){ continue; } var question=questions.eq(z).clone(); question.find('input[type="button"]').remove(); question.find('input[type="submit"]').remove(); question.find('.ays_arrow').remove(); question.addClass('ays_question_result'); var checked_inputs=question.find('input:checked'); var text_answer=question.find('textarea.ays-text-input'); var number_answer=question.find('input[type="number"].ays-text-input'); var short_text_answer=question.find('input[type="text"].ays-text-input'); var date_answer=question.find('input[type="date"].ays-text-input'); var selected_options=question.find('select'); var answerIsRight=false; if(showOnlyWrongAnswer===false){ question.find('input[name="ays_answer_correct[]"][value="1"]').parent().find('label').addClass('correct answered'); question.find('input[name="ays_answer_correct[]"][value="1"]').parents('div.ays-field').addClass('correct_div'); } if(checked_inputs.length===0){ var emptyAnswer=false; if(question.find('input[type="radio"]').length!==0){ emptyAnswer=true; } if(question.find('input[type="checkbox"]').length!==0){ emptyAnswer=true; } if(emptyAnswer){ question.find('.ays-abs-fs').html("
"+ "" + quizLangObj.notAnsweredText + ""+ question.find('.ays-abs-fs').html()+ "
"); question.find('.ays-abs-fs').css({ 'padding': '7px' }); }} var aysAudio=$(document).find('.ays_question_result audio'); if(aysAudio.length > 0){ aysAudio.each(function(e, el){ el.pause(); }); } selected_options.each(function(element, item){ var selectOptions=$(item).children("option[data-chisht]"); var selectedOption=$(item).children("option[data-chisht]:selected"); var answerClass, answerDivClass, attrChecked, answerClassForSelected, answerClass_tpel, answerViewClass, attrCheckedStyle="", attrCheckedStyle2; var prefixIcon='', attrCheckedStyle3='', attrCheckedStyle4; var correctAnswersDiv='', rectAnswerBefore=""; answerViewClass=form.parents('.ays-quiz-container').find('.answer_view_class').val(); answerViewClass="ays_"+form.find('.answer_view_class').val()+"_view_item"; for(var j=0; j < selectOptions.length; j++){ if($(selectOptions[j]).attr("value")==''||$(selectOptions[j]).attr("value")==undefined||$(selectOptions[j]).attr("value")==null){ continue; } if($(selectOptions[j]).prop('selected')==true){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerClassForSelected=" correct answered "; answerDivClass="correct_div checked_answer_div"; attrChecked="checked='checked'"; answerIsRight=true; }else{ answerClassForSelected=" wrong answered "; attrChecked="checked='checked'"; answerDivClass=" checked_answer_div "; }}else{ if(showOnlyWrongAnswer===false){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerClassForSelected=" correct answered "; answerDivClass="correct_div checked_answer_div"; attrChecked=""; }else{ answerClassForSelected=""; attrChecked=""; answerDivClass=""; }}else{ answerClassForSelected=""; attrChecked=""; answerDivClass=""; }} attrCheckedStyle2="style='padding:0 !important;'"; if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ if($(selectOptions[j]).prop('selected')==true){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ prefixIcon=''; attrCheckedStyle3=""; }else{ prefixIcon=''; attrCheckedStyle3="background-color: rgba(243,134,129,0.8);"; }}else{ if(showOnlyWrongAnswer===false){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ prefixIcon=''; attrCheckedStyle3=""; }else{ prefixIcon=''; attrCheckedStyle3=""; }}else{ prefixIcon=''; attrCheckedStyle3=""; }} attrCheckedStyle="style='display:block!important;"+attrCheckedStyle3+"'"; attrCheckedStyle2=""; answerViewClass=""; } if(form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') || form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){ if($(selectOptions[j]).prop('selected')==true){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerDivClass="correct_div checked_answer_div"; attrCheckedStyle="style='padding: 0!important;'"; }else{ answerDivClass="wrong_div checked_answer_div"; attrCheckedStyle="style='padding: 0!important;'"; }}else{ if(showOnlyWrongAnswer===false){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerDivClass="correct_div checked_answer_div"; }else{ answerDivClass=""; }}else{ answerDivClass=""; } attrCheckedStyle=""; }} if(form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_dark') || form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_light')){ if($(selectOptions[j]).prop('selected')==true){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerDivClass="correct_div checked_answer_div"; }else{ answerDivClass="wrong_div checked_answer_div"; } rectAnswerBefore="rect_answer_correct_before"; }else{ if(showOnlyWrongAnswer===false){ if(parseInt($(selectOptions[j]).data("chisht"))===1){ answerDivClass="correct_div checked_answer_div"; }else{ answerDivClass=""; }}else{ answerDivClass=""; } rectAnswerBefore="rect_answer_wrong_before"; }} correctAnswersDiv +='
' + '' + ' ' + '' + '
'; } $(item).parent().parent().find('.ays-text-right-answer').remove(); $(item).parent().parent().append(correctAnswersDiv); $(item).parent().hide(); if(selectedOption.length===0){ var emptySelectHtml="
"+ "" + quizLangObj.notAnsweredText + ""+ $(item).parents('.ays-abs-fs').html()+ "
"; $(item).parents('.ays-abs-fs').html(emptySelectHtml); $(item).parents('.ays-abs-fs').css({ 'padding': '7px' }); } $(item).parents('.ays-abs-fs').find('.ays_buttons_div').remove(); $(item).parent().remove(); }); text_answer.next().next().remove(); text_answer.css('width', '100%'); text_answer.attr('disabled', 'disabled'); number_answer.next().next().remove(); number_answer.css('width', '100%'); number_answer.attr('disabled', 'disabled'); short_text_answer.next().next().remove(); short_text_answer.css('width', '100%'); short_text_answer.attr('disabled', 'disabled'); date_answer.next().next().remove(); date_answer.css('width', '100%'); date_answer.attr('disabled', 'disabled'); if(text_answer.val()==''){ if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=text_answer.attr('chishtpatasxan'); if(typeof thisQuestionAnswer!='undefined'){ thisQuestionAnswer=thisQuestionAnswer.toLowerCase().split('%%%'); }else{ thisQuestionAnswer=['']; } rightAnswerText +=thisQuestionAnswer[0].trim(); rightAnswerText +='
'; if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ text_answer.parents('.ays-quiz-answers').append(rightAnswerText); } text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').show(); } text_answer.css('background-color', 'rgba(243,134,129,0.4)'); text_answer.parents('.ays-abs-fs').html("
"+ "" + quizLangObj.notAnsweredText + ""+ text_answer.parents('.ays-abs-fs').html()+ "
"); text_answer.parents('.ays-abs-fs').css({ 'padding': '7px' }); }else{ if(parseInt(text_answer.next().val())==1){ text_answer.css('background-color', 'rgba(39,174,96,0.5)'); answerIsRight=true; }else{ text_answer.css('background-color', 'rgba(243,134,129,0.4)'); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=text_answer.attr('chishtpatasxan'); if(typeof thisQuestionAnswer!='undefined'){ thisQuestionAnswer=thisQuestionAnswer.toLowerCase().split('%%%'); }else{ thisQuestionAnswer=['']; } rightAnswerText +=thisQuestionAnswer[0].trim(); rightAnswerText +='
'; if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ text_answer.parents('.ays-quiz-answers').append(rightAnswerText); } text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); }} } if(number_answer.val()==''){ if(showOnlyWrongAnswer===false){ var rightAnswerText='
'+ number_answer.attr('chishtpatasxan')+ '
'; if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ number_answer.parents('.ays-quiz-answers').append(rightAnswerText); } number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').show(); } number_answer.css('background-color', 'rgba(243,134,129,0.8)'); number_answer.parents('.ays-abs-fs').html("
"+ "" + quizLangObj.notAnsweredText + ""+ number_answer.parents('.ays-abs-fs').html()+ "
"); number_answer.parents('.ays-abs-fs').css({ 'padding': '7px' }); }else{ if(parseInt(number_answer.next().val())==1){ number_answer.css('background-color', 'rgba(39,174,96,0.5)'); answerIsRight=true; }else{ number_answer.css('background-color', 'rgba(243,134,129,0.4)'); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'+ number_answer.attr('chishtpatasxan')+ '
'; if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ number_answer.parents('.ays-quiz-answers').append(rightAnswerText); } number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); }} } if(short_text_answer.val()==''){ if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=short_text_answer.attr('chishtpatasxan'); if(typeof thisQuestionAnswer!='undefined'){ thisQuestionAnswer=thisQuestionAnswer.toLowerCase().split('%%%'); }else{ thisQuestionAnswer=['']; } rightAnswerText +=thisQuestionAnswer[0].trim(); rightAnswerText +='
'; if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText); } short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').show(); } short_text_answer.css('background-color', 'rgba(243,134,129,0.8)'); short_text_answer.parents('.ays-abs-fs').html("
"+ "" + quizLangObj.notAnsweredText + ""+ short_text_answer.parents('.ays-abs-fs').html()+ "
"); short_text_answer.parents('.ays-abs-fs').css({ 'padding': '7px' }); }else{ if(parseInt(short_text_answer.next().val())==1){ short_text_answer.css('background-color', 'rgba(39,174,96,0.5)'); answerIsRight=true; }else{ short_text_answer.css('background-color', 'rgba(243,134,129,0.4)'); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=short_text_answer.attr('chishtpatasxan'); if(typeof thisQuestionAnswer!='undefined'){ thisQuestionAnswer=thisQuestionAnswer.toLowerCase().split('%%%'); }else{ thisQuestionAnswer=['']; } rightAnswerText +=thisQuestionAnswer[0].trim(); rightAnswerText +='
'; if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText); } short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); }} } if(date_answer.val()==''){ if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=date_answer.attr('chishtpatasxan'); var correctDate=new Date(thisQuestionAnswer), correctDateYear=correctDate.getFullYear(), correctDateMonth=(correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1):(correctDate.getMonth() + 1), correctDateDay=(correctDate.getDate() < 10) ? "0"+correctDate.getDate():correctDate.getDate(); rightAnswerText +=[correctDateMonth, correctDateDay, correctDateYear].join('/'); rightAnswerText +='
'; if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ date_answer.parents('.ays-quiz-answers').append(rightAnswerText); } date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').show(); } date_answer.css('background-color', 'rgba(243,134,129,0.8)'); date_answer.parents('.ays-abs-fs').html("
"+ "" + quizLangObj.notAnsweredText + ""+ date_answer.parents('.ays-abs-fs').html()+ "
"); date_answer.parents('.ays-abs-fs').css({ 'padding': '7px' }); }else{ if(parseInt(date_answer.next().val())==1){ date_answer.css('background-color', 'rgba(39,174,96,0.5)'); answerIsRight=true; }else{ date_answer.css('background-color', 'rgba(243,134,129,0.4)'); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; var thisQuestionAnswer=date_answer.attr('chishtpatasxan'); var correctDate=new Date(thisQuestionAnswer), correctDateYear=correctDate.getFullYear(), correctDateMonth=(correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1):(correctDate.getMonth() + 1), correctDateDay=(correctDate.getDate() < 10) ? "0"+correctDate.getDate():correctDate.getDate(); rightAnswerText +=[correctDateMonth, correctDateDay, correctDateYear].join('/'); rightAnswerText +='
'; if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length==0){ date_answer.parents('.ays-quiz-answers').append(rightAnswerText); } date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); }} } if(checked_inputs.length===1){ if(parseInt(checked_inputs.prev().val())===1){ checked_inputs.parent().addClass('checked_answer_div').addClass('correct_div'); checked_inputs.next().addClass('correct answered'); answerIsRight=true; if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ $(checked_inputs).next().css('background-color', "transparent"); $(checked_inputs).parent().css('background-color', ' rgba(158,208,100,0.8)'); }}else{ if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ $(checked_inputs).next().css('background-color', "transparent"); $(checked_inputs).parent().css('background-color', ' rgba(243,134,129,0.8)'); } checked_inputs.parent().addClass('checked_answer_div').addClass('wrong_div'); checked_inputs.next().addClass('wrong wrong_div answered'); } if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){ $(this).next().css('padding', "0 10px 0 10px"); } $(checked_inputs).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true); }else if(checked_inputs.length > 1){ var checked_right=0; checked_inputs.map(function(){ if(parseInt($(this).prev().val())===1){ $(this).parent().addClass('checked_answer_div').addClass('correct_div'); $(this).next().addClass('correct answered'); if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ $(this).next().css('background-color', "transparent"); $(this).parent().css('background-color', ' rgba(158,208,100,0.8)'); }}else{ $(this).parent().addClass('checked_answer_div').addClass('wrong_div'); $(this).next().addClass('wrong wrong_div answered'); checked_right++; if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ $(this).next().css('background-color', "transparent"); $(this).parent().css('background-color', ' rgba(243,134,129,0.8)'); }} if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){ } if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') || $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){ } $(this).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true); }); if(checked_right==0){ answerIsRight=true; }} if(myOptions.answers_rw_texts&&(myOptions.answers_rw_texts=='on_results_page'||myOptions.answers_rw_texts=='on_both')){ if(answerIsRight){ question.find('.right_answer_text').css("display", "block"); }else{ question.find('.wrong_answer_text').css("display", "block"); }}else{ question.find('.right_answer_text').css("display", "none"); question.find('.wrong_answer_text').css("display", "none"); } question.find('.ays_questtion_explanation').css("display", "block"); question.find('.ays_user_explanation').css("display", "none"); question.css("pointer-events", "auto"); question.find('.ays-quiz-answers').css("pointer-events", "none"); formResults.append(question); }} form.find('.ays_quiz_results').slideDown(1000); form.find('.ays_quiz_rete').fadeIn(250); form.find('.for_quiz_rate').rating({ onRate: function(res){ $(this).rating('disable'); $(this).parent().find('.for_quiz_rate_reason').slideDown(500); $(this).parents('.ays_quiz_rete').attr('data-rate_score', res); }}); var aysQuizLoader=form.find('div[data-role="loader"]'); aysQuizLoader.addClass('ays-loader'); aysQuizLoader.removeClass(aysQuizLoader.data('class')); form.find('.ays_quiz_results_page').css({'display':'block'}); form.css({'display':'block'}); form.find('.ays_quiz_rete .for_quiz_rate_reason .action-button').on('click', function(){ $(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').attr('disabled', 'disabled'); var data={}; var quizId=form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); data.action='ays_rate_the_quiz'; data.rate_reason=$(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').val(); data.rate_score=$(this).parents('.ays_quiz_rete').data('rate_score'); data.rate_date=GetFullDateTime(); data.quiz_id=quizId; form.find('.for_quiz_rate_reason').slideUp(800); var showAvgRate=false; myOptions.show_rate_after_rate=(myOptions.show_rate_after_rate) ? myOptions.show_rate_after_rate:'on'; if(myOptions.show_rate_after_rate&&myOptions.show_rate_after_rate=='on'){ showAvgRate=true; } if(showAvgRate){ $(this).parents('.ays_quiz_rete').find('.lds-spinner-none').addClass('lds-spinner').removeClass('lds-spinner-none'); } if(myOptions.enable_quiz_rate=='on'&&myOptions.enable_rate_comments=='on'){ $(this).parents('.ays_quiz_rete').find('.lds-spinner2-none').addClass('lds-spinner2').removeClass('lds-spinner2-none'); } $.ajax({ url: quiz_maker_ajax_public.ajax_url, method: 'post', dataType: 'json', data: data, success: function(response){ if(response.status===true){ setTimeout(function(){ form.find('.ays_quiz_rete').find('.for_quiz_rate').attr('data-rating', response.score); form.find('.ays_quiz_rete').find('.for_quiz_rate').rating({ initialRating: response.score }); form.find('.ays_quiz_rete').find('.for_quiz_rate').rating('disable'); if(showAvgRate){ form.find('.lds-spinner').addClass('lds-spinner-none').removeClass('lds-spinner'); form.find('.for_quiz_rate_reason').html('

'+response.rates_count + ' votes, '+response.avg_score + ' avg

'); form.find('.for_quiz_rate_reason').fadeIn(250); } if(myOptions.enable_quiz_rate=='on'&&myOptions.enable_rate_comments=='on'){ var data={}; data.action='ays_get_rate_last_reviews'; data.quiz_id=response.quiz_id; $.ajax({ url: quiz_maker_ajax_public.ajax_url, method: 'post', data: data, success: function(response){ form.find('.quiz_rate_reasons_body').html(response); form.find('.lds-spinner2').addClass('lds-spinner2-none').removeClass('lds-spinner2'); form.find('.quiz_rate_reasons_container').slideDown(500); form.find('button.ays_load_more_review').on('click', function(e){ form.find('.quiz_rate_load_more [data-role="loader"]').addClass(form.find('.quiz_rate_load_more .ays-loader').data('class')).removeClass('ays-loader'); var startFrom=parseInt($(e.target).attr('startfrom')); var zuyga=parseInt($(e.target).attr('zuyga')); $.ajax({ url: quiz_maker_ajax_public.ajax_url, method: 'post', data:{ action: 'ays_load_more_reviews', quiz_id: quizId, start_from: startFrom, zuyga: zuyga }, success: function(resp){ if(zuyga==0){ zuyga=1; }else{ zuyga=0; } form.find('.quiz_rate_load_more [data-role="loader"]').addClass('ays-loader').removeClass(form.find('.quiz_rate_load_more .ays-loader').data('class')); form.find('.quiz_rate_reasons_container').append(resp); form.find('.quiz_rate_more_review:last-of-type').slideDown(500); $(e.target).attr('startfrom', startFrom + 5); $(e.target).attr('zuyga', zuyga); if(form.find('.quiz_rate_reasons_container p.ays_no_more').length > 0){ $(e.target).remove(); }} }); }); }, error: function(jqXHR, textStatus, errorThrown){}}); }},1000); }} }); }); if(myOptions.redirect_after_submit&&myOptions.redirect_after_submit=='on'){ var ays_block_element=form.parents('.ays-quiz-container'); var timer=parseInt(myOptions.submit_redirect_delay); if(timer===NaN){ timer=0; } var tabTitle=document.title; var timerText=$('
'+ '
'+ 'Redirecting after ' + myOptions.submit_redirect_after + '

'); form.parents('.ays-quiz-container').prepend(timerText); ays_block_element.find('.ays_quiz_timer_container').css({ height: 'auto' }); setTimeout(function(){ if(timer!==NaN){ timer +=2; if(timer!==undefined){ var countDownDate=new Date().getTime() + (timer * 1000); ays_block_element.find('div.ays-quiz-timer').slideUp(500); var x=setInterval(function (){ var now=new Date().getTime(); var distance=countDownDate - Math.ceil(now/1000)*1000; var hours=Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes=Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds=Math.floor((distance % (1000 * 60)) / 1000); var timeForShow=""; if(hours <=0){ hours=null; }else if(hours < 10){ hours='0' + hours; } if(minutes < 10){ minutes='0' + minutes; } if(seconds < 10){ seconds='0' + seconds; } timeForShow=((hours==null)? "":(hours + ":")) + minutes + ":" + seconds; if(distance <=1000){ timeForShow=((hours==null) ? "":"00:") + "00:00"; ays_block_element.find('div.ays-quiz-timer').html(timeForShow); document.title=timeForShow + " - " + tabTitle; }else{ ays_block_element.find('div.ays-quiz-timer').html(timeForShow); document.title=timeForShow + " - " + tabTitle; } ays_block_element.find('div.ays-quiz-timer').slideDown(500); var ays_block_element_redirect_url=myOptions.submit_redirect_url; if(distance <=1000){ clearInterval(x); window.location=ays_block_element_redirect_url; }}, 1000); }} }, 2000); }} })(jQuery); (function ($){ 'use strict'; $(document).ready(function (){ $.fn.goTo=function(){ $('html, body').animate({ scrollTop: $(this).offset().top - 100 + 'px' }, 'slow'); return this; } if(!String.prototype.trim){ (function(){ String.prototype.trim=function(){ return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); };})(); } $(document).find('.for_quiz_rate_avg.ui.rating').rating('disable'); var ays_quiz_container, ays_quiz_container_id; var myOptions, myQuizOptions, explanationTimeout; var emailValivatePattern=/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/; function time_limit(e){ var quizId=$(e.target).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val(); myOptions=JSON.parse(atob(window.aysQuizOptions[quizId])); if(checkQuizPassword(e, myOptions, false)===false){ return false; } if(typeof myOptions.answers_rw_texts=='undefined'){ myOptions.answers_rw_texts='on_passing'; } if(typeof myOptions.make_questions_required=='undefined'){ myOptions.make_questions_required='off'; } var quizOptionsName='quizOptions_'+quizId; myQuizOptions=[]; if(typeof window[quizOptionsName]!=='undefined'){ for(var i in window[quizOptionsName]){ myQuizOptions[i]=(JSON.parse(window.atob(window[quizOptionsName][i]))); }} if($(this).parents('.step').next().find('.information_form').length===0){ var quizMusic=$(e.target).parents('.ays-quiz-container').find('.ays_quiz_music'); if(quizMusic.length!==0){ var soundEls=$(document).find('.ays_music_sound'); $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').removeClass('ays_display_none'); if(!isPlaying(quizMusic.get(0))){ $(e.target).parents('.ays-quiz-container').find('.ays_quiz_music')[0].play(); audioVolumeIn($(e.target).parents('.ays-quiz-container').find('.ays_quiz_music')[0]); }} $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css({'display': 'block'}); $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').css({'display': 'inline-block'}); $(e.target).parents('.ays-quiz-container').find('input.ays-start-date').val(GetFullDateTime()); } if($(this).parents('.step').next().find('.information_form').length===0&&myOptions.enable_timer=='on'){ $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').hide(800); var timer=parseInt($(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').attr('data-timer')); var pageTitle=$(document).find('title'); var pageTitleText=$(document).find('title').html(); var timeForShow=""; if(!isNaN(timer)&&myOptions.timer!==undefined){ if(myOptions.timer===timer&&timer!==0){ timer +=2; if(timer!==undefined){ var countDownDate=new Date().getTime() + (timer * 1000); var x=setInterval(function (){ var now=new Date().getTime(); var distance=countDownDate - Math.ceil(now/1000)*1000; var hours=Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes=Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds=Math.floor((distance % (1000 * 60)) / 1000); var sec=seconds; var min=minutes; var hour=hours; if(hours <=0){ hours=null; }else if(hours < 10){ hours='0' + hours; } if(minutes < 10){ minutes='0' + minutes; } if(seconds < 10){ seconds='0' + seconds; } timeForShow=((hours==null)? "":(hours + ":")) + minutes + ":" + seconds; if(distance <=1000){ timeForShow=((hours==null) ? "":"00:") + "00:00"; $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').html(timeForShow); if(myOptions.quiz_timer_in_title=='on'){ pageTitle.html(timeForShow + " - " + pageTitleText); }}else{ $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').html(timeForShow); if(myOptions.quiz_timer_in_title=='on'){ pageTitle.html(timeForShow + " - " + pageTitleText); }} $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').show(); $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').show(500); if($(e.target).parents('.ays-quiz-container').find('.ays-quiz-timer').length===0){ clearInterval(x); if(myOptions.quiz_timer_in_title=='on'){ pageTitle.html(pageTitleText); } $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').slideUp(500); } if($(e.target).parents('.ays-quiz-container').find('.ays_finish.action-button').hasClass("ays_timer_end") || $(e.target).parents('.ays-quiz-container').find('.ays_next.action-button').hasClass("ays_timer_end")){ clearInterval(x); if(myOptions.quiz_timer_in_title=='on'){ pageTitle.html(pageTitleText); } $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').slideUp(500); } if(hour==0&&min==0&&sec < 1){ $(e.target).parents('.ays-quiz-container').find('.ays_buttons_div > *:not(input.ays_finish)').off('click'); } if(distance <=1){ clearInterval(x); if(! $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){ $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').css({ 'position': 'static', 'height': '100%', }); $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').show(); $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-timer').slideUp(); $(e.target).parents('.ays-quiz-container').find('div.ays-quiz-after-timer').slideDown(500); }else{ $(e.target).parents('.ays-quiz-container').find('.ays_quiz_timer_container').slideUp(500); } if(myOptions.quiz_timer_in_title=='on'){ pageTitle.html(pageTitleText); } var totalSteps=$(e.target).parents('.ays-quiz-container').find('div.step').length; var currentStep=$(e.target).parents('.ays-quiz-container').find('div.step.active-step'); var thankYouStep=$(e.target).parents('.ays-quiz-container').find('div.step.ays_thank_you_fs'); var infoFormLast=thankYouStep.prev().find('div.information_form'); if(infoFormLast.length==0){ if(currentStep.hasClass('ays_thank_you_fs')===false){ var steps=totalSteps - 3; $(e.target).parents('.ays-quiz-container').find('div.step').each(function (index){ if($(this).hasClass('ays_thank_you_fs')){ $(this).addClass('active-step') }else{ $(this).css('display', 'none'); }}); $(e.target).parents('.ays-quiz-container').find('input.ays_finish').trigger('click'); }}else{ if(currentStep.parents('.ays-quiz-container').find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){ currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().slideUp(500); } $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').css('display','none'); },300); aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, infoFormLast.parent()); $(e.target).parents('.ays-quiz-container').find('div.step').each(function (index){ $(this).css('display', 'none'); $(this).removeClass('active-step') }); infoFormLast.parent().addClass('active-step'); }} }, 1000); }}else{ alert('Wanna cheat??'); window.location.reload(); }} }else{ $(this).parents('.step').next().find('.information_form').find('.ays_next.action-button').on('click', function (){ if($(this).parents('.step').find('.information_form').find('.ays_next.action-button').hasClass('ays_start_allow')){ time_limit(e); }}); }} $(document).find('.ays_next.start_button').on('click', time_limit); $(document).find('.ays_next.start_button').on('click', function(e){ if(typeof $(this).attr("data-enable-leave-page")!=='undefined'){ $(this).attr("data-enable-leave-page",true); } if(checkQuizPassword(e, myOptions, false)===false){ return false; } ays_quiz_container_id=$(this).parents(".ays-quiz-container").attr("id"); ays_quiz_container=$('#'+ays_quiz_container_id); aysResetQuiz(ays_quiz_container); ays_quiz_container.css('padding-bottom', '0px'); var ancnoxneriQanak=$(this).parents('.ays-questions-container').find('.ays_quizn_ancnoxneri_qanak'); var aysQuizReteAvg=$(this).parents('.ays-questions-container').find('.ays_quiz_rete_avg'); var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(isRequiredQuestion===true){ ays_quiz_container.find('div[data-question-id]').each(function(){ var thisStep=$(this); if(!thisStep.find('input.ays_next').hasClass('ays_display_none')){ thisStep.find('input.ays_next').attr('disabled', 'disabled'); }else if(!thisStep.find('i.ays_next_arrow').hasClass('ays_display_none')){ thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled'); } if(!thisStep.find('input.ays_early_finish').hasClass('ays_display_none')){ thisStep.find('input.ays_early_finish').attr('disabled', 'disabled'); }else if(!thisStep.find('i.ays_early_finish').hasClass('ays_display_none')){ thisStep.find('i.ays_early_finish').attr('disabled', 'disabled'); }}); } setTimeout(function(){ ays_quiz_container.css('border-radius', myOptions.quiz_border_radius + 'px'); ays_quiz_container.find('.step').css('border-radius', myOptions.quiz_border_radius + 'px'); }, 400); aysAnimateStep(ays_quiz_container.data('questEffect'), aysQuizReteAvg); aysAnimateStep(ays_quiz_container.data('questEffect'), ancnoxneriQanak); if($(this).parents('.step').next().find('.information_form').length===0){ var questions_count=$(this).parents('form').find('div[data-question-id]').length; var curent_number=$(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; var next_sibilings_count=$(this).parents('form').find('.ays_question_count_per_page').val(); if(questions_count <=parseInt(next_sibilings_count)){ next_sibilings_count=questions_count; } if(parseInt(next_sibilings_count) > 0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){ var final_width=((parseInt(next_sibilings_count)) / questions_count * 100) + "%"; if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(parseInt(next_sibilings_count))); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); }else{ var final_width=((curent_number+1) / questions_count * 100) + "%"; if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); }} }); $(document).find('.ays-quiz-container input').on('focus', function (){ $(window).on('keydown', function (event){ if(event.keyCode===13){ return false; }}); }); $(document).find('.ays-quiz-container input').on('blur', function (){ $(window).off('keydown'); }); $.each($(document).find('.ays_block_content'), function (){ if($(document).find('.ays_block_content').length!=0){ var ays_block_element=$(this).parents().eq(2); ays_block_element.find('input.ays-start-date').val(GetFullDateTime()); ays_block_element.find('div.ays-quiz-timer').slideUp(500); var timer=parseInt(ays_block_element.find('div.ays-quiz-timer').attr('data-timer')); var timerInTitle=ays_block_element.find('div.ays-quiz-timer').data('showInTitle'); var tabTitle=document.title; setTimeout(function(){ if(timer!==NaN){ timer +=2; if(timer!==undefined){ var countDownDate=new Date().getTime() + (timer * 1000); var x=setInterval(function (){ var now=new Date().getTime(); var distance=countDownDate - Math.ceil(now/1000)*1000; var hours=Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes=Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds=Math.floor((distance % (1000 * 60)) / 1000); var timeForShow=""; if(hours <=0){ hours=null; }else if(hours < 10){ hours='0' + hours; } if(minutes < 10){ minutes='0' + minutes; } if(seconds < 10){ seconds='0' + seconds; } timeForShow=((hours==null)? "":(hours + ":")) + minutes + ":" + seconds; if(distance <=1000){ timeForShow=((hours==null) ? "":"00:") + "00:00"; ays_block_element.find('div.ays-quiz-timer').html(timeForShow); if(timerInTitle){ document.title=timeForShow + " - " + tabTitle ; }}else{ ays_block_element.find('div.ays-quiz-timer').html(timeForShow); if(timerInTitle){ document.title=timeForShow + " - " + tabTitle ; }} ays_block_element.find('div.ays-quiz-timer').slideDown(500); var ays_block_element_redirect_url=ays_block_element.find('.ays_redirect_url').text(); if(distance <=1){ clearInterval(x); var totalSteps=ays_block_element.find('div.step').length; var currentStep=ays_block_element.eq(2).find('div.step.active-step'); var currentStepIndex=ays_block_element.eq(2).find('div.step.active-step').index(); if(currentStep.hasClass('ays_thank_you_fs')===false){ var steps=totalSteps - 3; ays_block_element.find('div.step').each(function (index){ if(index >=(currentStepIndex - 1)&&index <=steps){ $(this).remove(); }}); window.location=ays_block_element_redirect_url; }} }, 1000); }} }, 1000); }}); $(document).find('button.ays_check_answer').on('click', function (e){ var thisAnswerOptions; var quizContainer=$(e.target).parents('.ays-quiz-container'); var right_answer_sound=quizContainer.find('.ays_quiz_right_ans_sound').get(0); var wrong_answer_sound=quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); var questionId=$(this).parents('.step').data('questionId'); var finishAfterWrongAnswer=(myOptions.finish_after_wrong_answer&&myOptions.finish_after_wrong_answer=="on") ? true:false; var showOnlyWrongAnswer=(myOptions.show_only_wrong_answer&&myOptions.show_only_wrong_answer=="on") ? true:false; thisAnswerOptions=myQuizOptions[questionId]; if($(this).parent().find('.ays-text-input').val()!==""){ if($(e.target).parents('form[id^="ays_finish_quiz"]').hasClass('enable_correction')){ if($(e.target).parents('.step').hasClass('not_influence_to_score')){ return false; } $(this).css({ animation: "bounceOut .5s", }); setTimeout(function(){ $(e.target).parent().find('.ays-text-input').css('width', '100%'); $(e.target).css("display", "none"); },480); $(e.target).parent().find('.ays-text-input').css('background-color', '#eee'); $(this).parent().find('.ays-text-input').attr('disabled', 'disabled'); $(this).attr('disabled', 'disabled'); $(this).off('change'); $(this).off('click'); var input=$(this).parent().find('.ays-text-input'); var type=input.attr('type'); var userAnsweredText=input.val().trim(); var trueAnswered=false; var thisQuestionAnswer=thisAnswerOptions.question_answer.toLowerCase(); if(type=='date'){ var correctDate=new Date(thisAnswerOptions.question_answer), correctDateYear=correctDate.getFullYear(), correctDateMonth=correctDate.getMonth(), correctDateDay=correctDate.getDate(); var userDate=new Date(userAnsweredText), userDateYear=userDate.getFullYear(), userDateMonth=userDate.getMonth(), userDateDay=userDate.getDate(); if(correctDateYear==userDateYear&&correctDateMonth==userDateMonth&&correctDateDay==userDateDay){ trueAnswered=true; }}else if(type!='number'){ thisQuestionAnswer=thisQuestionAnswer.split('%%%'); for(var i=0; i < thisQuestionAnswer.length; i++){ if(userAnsweredText.toLowerCase()==thisQuestionAnswer[i].trim()){ trueAnswered=true; break; }} }else{ if(userAnsweredText.toLowerCase()==thisQuestionAnswer.trim()){ trueAnswered=true; }} if(trueAnswered){ if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); } $(this).parent().find('.ays-text-input').css('background-color', 'rgba(39,174,96,0.5)'); $(this).parent().find('input[name="ays_answer_correct[]"]').val(1); }else{ if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); } $(this).parent().find('.ays-text-input').css('background-color', 'rgba(243,134,129,0.8)'); $(this).parent().find('input[name="ays_answer_correct[]"]').val(0); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'; if(type=='date'){ var correctDate=new Date(thisAnswerOptions.question_answer), correctDateYear=correctDate.getFullYear(), correctDateMonth=(correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1):(correctDate.getMonth() + 1), correctDateDay=(correctDate.getDate() < 10) ? "0"+correctDate.getDate():correctDate.getDate(); rightAnswerText +=[correctDateMonth, correctDateDay, correctDateYear].join('/'); }else if(type!='number'){ rightAnswerText +=thisQuestionAnswer[0]; }else{ rightAnswerText +=thisQuestionAnswer; } rightAnswerText +='
'; $(this).parents('.ays-quiz-answers').append(rightAnswerText); $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); } if(finishAfterWrongAnswer){ goToLastPage(e); }} }} }); $(document).on('change', 'input[name^="ays_questions"]', function (e){ var quizContainer=$(e.target).parents('.ays-quiz-container'); if(typeof myOptions!='undefined'){ var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(isRequiredQuestion===true){ if($(e.target).attr('type')==='radio'||$(e.target).attr('type')==='checkbox'){ if($(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]:checked').length!=0){ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled'); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled'); }}else{ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true); }} }} } if($(e.target).parents('.step').hasClass('not_influence_to_score')){ if($(e.target).attr('type')==='radio'){ $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div'); $(e.target).parents('.ays-field').addClass('checked_answer_div'); } if($(e.target).attr('type')==='checkbox'){ if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){ $(e.target).parents('.ays-field').addClass('checked_answer_div'); }else{ $(e.target).parents('.ays-field').removeClass('checked_answer_div'); }} var checked_inputs=$(e.target).parents().eq(1).find('input:checked'); if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')&&checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ if(checked_inputs.attr('type')==='radio'){ checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); }} if($(e.target).parents().eq(4).hasClass('enable_correction')){ if(checked_inputs.attr('type')==="radio"){ $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change'); }else if(checked_inputs.attr('type')==="checkbox"){ $(e.target).attr('disabled', true); $(e.target).off('change'); }} return false; } if($(e.target).parents().eq(4).hasClass('enable_correction')){ var right_answer_sound=quizContainer.find('.ays_quiz_right_ans_sound').get(0); var wrong_answer_sound=quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); var finishAfterWrongAnswer=(myOptions.finish_after_wrong_answer&&myOptions.finish_after_wrong_answer=="on") ? true:false; var showOnlyWrongAnswer=(myOptions.show_only_wrong_answer&&myOptions.show_only_wrong_answer=="on") ? true:false; if($(e.target).parents().eq(1).find('input[name="ays_answer_correct[]"]').length!==0){ var checked_inputs=$(e.target).parents().eq(1).find('input:checked'); if(checked_inputs.attr('type')==="radio"){ checked_inputs.nextAll().addClass('answered'); checked_inputs.parent().addClass('checked_answer_div'); if(checked_inputs.prev().val()==1){ checked_inputs.nextAll().addClass('correct') checked_inputs.parent().addClass('correct_div'); }else{ checked_inputs.nextAll().addClass('wrong'); checked_inputs.parent().addClass('wrong_div'); } if(checked_inputs.prev().val()==1){ if(myOptions.answers_rw_texts&&(myOptions.answers_rw_texts=='on_passing'||myOptions.answers_rw_texts=='on_both')){ var explanationTime=myOptions.explanation_time&&myOptions.explanation_time!="" ? parseInt(myOptions.explanation_time):4; if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){ $(e.target).parents().eq(3).find('.right_answer_text').slideDown(250); } explanationTimeout=setTimeout(function(){ if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); }}, explanationTime * 1000); }else{ if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); }} if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); }}else{ if(showOnlyWrongAnswer===false){ $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').parent().addClass('correct_div').addClass('checked_answer_div'); $(e.target).parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').nextAll().addClass('correct answered'); } if(myOptions.answers_rw_texts&&(myOptions.answers_rw_texts=='on_passing'||myOptions.answers_rw_texts=='on_both')){ var explanationTime=myOptions.explanation_time&&myOptions.explanation_time!="" ? parseInt(myOptions.explanation_time):4; if(! $(e.target).parents('.step').hasClass('not_influence_to_score')){ $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(250); } if(finishAfterWrongAnswer){ checked_inputs.parents('div[data-question-id]').find('.ays_next').attr('disabled', 'disabled'); checked_inputs.parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled'); } explanationTimeout=setTimeout(function(){ if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ if(finishAfterWrongAnswer){ goToLastPage(e); }else{ checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); }}else{ if(finishAfterWrongAnswer){ goToLastPage(e); }} }, explanationTime * 1000); }else{ if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ if(finishAfterWrongAnswer){ goToLastPage(e); }else{ checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click'); }}else{ if(finishAfterWrongAnswer){ goToLastPage(e); }} } if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); }} $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change'); $(e.target).parents('div[data-question-id]').find('.ays-field').css({ 'pointer-events': 'none' }); }else if(checked_inputs.attr('type')==="checkbox"){ checked_inputs=$(e.target); if(checked_inputs.length===1){ checked_inputs.parent().addClass('checked_answer_div'); if(checked_inputs.prev().val()==1){ if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); } checked_inputs.parent().addClass('correct_div'); checked_inputs.nextAll().addClass('correct answered'); }else{ if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); } if(finishAfterWrongAnswer){ goToLastPage(e); } checked_inputs.parent().addClass('wrong_div'); checked_inputs.nextAll().addClass('wrong answered'); }}else{ for (var i=0; i < checked_inputs.length; i++){ if(checked_inputs.eq(i).prev().val()==1){ if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); } checked_inputs.eq(i).nextAll().addClass('correct answered'); checked_inputs.eq(i).parent().addClass('correct_div'); checked_inputs.eq(i).parent().addClass('checked_answer_div'); }else{ if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); } if(finishAfterWrongAnswer){ goToLastPage(e); } checked_inputs.eq(i).parent().addClass('checked_answer_div'); checked_inputs.eq(i).nextAll().addClass('wrong answered'); checked_inputs.eq(i).parent().addClass('wrong_div'); }} if(checked_inputs.eq(i).prev().val()==1){ checked_inputs.eq(i).next().addClass('correct answered'); if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); }}else{ checked_inputs.eq(i).next().addClass('wrong answered'); if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); }} } $(e.target).attr('disabled', true); $(e.target).off('change'); }} }else{ if($(e.target).attr('type')==='radio'){ $(e.target).parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div'); $(e.target).parents('.ays-field').addClass('checked_answer_div'); } if($(e.target).attr('type')==='checkbox'){ if(!$(e.target).parents('.ays-field').hasClass('checked_answer_div')){ $(e.target).parents('.ays-field').addClass('checked_answer_div'); }else{ $(e.target).parents('.ays-field').removeClass('checked_answer_div'); }} var checked_inputs=$(e.target).parents().eq(1).find('input:checked'); if(checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ if(checked_inputs.attr('type')==='radio'){ checked_inputs.parents('div[data-question-id]').find('input.ays_next').trigger('click'); }} }}); $(document).on('input', 'textarea[name^="ays_questions"], input[name^="ays_questions"]', function (e){ if(typeof myOptions!='undefined'){ var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(isRequiredQuestion===true){ if($(e.target).attr('type')==='text' || $(e.target).attr('type')==='number' || $(e.target).attr('type')==='date'){ if($(e.target).val()!=''){ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled'); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled'); }}else{ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true); }} }} }}); $(document).on('input', '.information_form input[name="ays_user_phone"]', function(){ if($(this).attr('type')!=='hidden'){ $(this).removeClass('ays_red_border'); $(this).removeClass('ays_green_border'); if($(this).val()!=''){ if(!validatePhoneNumber($(this).get(0))){ $(this).addClass('ays_red_border'); }else{ $(this).addClass('ays_green_border'); }} }}); $(document).on('input', 'input.ays_quiz_password', function(e){ var $this=$(this); var startButton=$this.parents('.ays-quiz-container').find('input.start_button'); if($this.val()!=''){ startButton.removeAttr('disabled'); }else{ startButton.attr('disabled', 'disabled'); }}); setTimeout(function(){ $(document).find('input.ays_quiz_password').val(''); }, 500); $(document).on('input', '.information_form input[name="ays_user_email"], .information_form input[type="email"]', function(){ if($(this).attr('type')!=='hidden'){ $(this).removeClass('ays_red_border'); $(this).removeClass('ays_green_border'); if($(this).val()!=''){ if(!(emailValivatePattern.test($(this).val()))){ $(this).addClass('ays_red_border'); }else{ $(this).addClass('ays_green_border'); }} }}); $(document).find('.ays-text-field .ays-text-input').each(function(ev){ $(this).on('keydown', function(e){ myOptions.enable_enter_key = !(myOptions.enable_enter_key) ? "on":myOptions.enable_enter_key; var enableEnterKey=(myOptions.enable_enter_key&&myOptions.enable_enter_key=="on") ? true:false; var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(enableEnterKey){ if(e.keyCode===13&&!e.shiftKey){ if(animating){ return false; } if(isRequiredQuestion===true){ if($(this).val()==''){ return false; }} if($(this).parents('.step').find('input.ays_finish.action-button').length > 0){ $(this).parents('.step').find('input.ays_finish.action-button').trigger('click'); }else{ $(this).parents('.step').find('input.ays_next.action-button').trigger('click'); } $(this).trigger('blur'); return false; }} }); }); $(document).find('.ays_next').on('click', function(e){ e.preventDefault(); if(checkQuizPassword(e, myOptions, true)===false){ return false; } ays_quiz_container=$(this).parents(".ays-quiz-container"); if(!($(this).hasClass('start_button'))){ if($(this).parents('.step').find('input[required]').length!==0){ var empty_inputs=0; var required_inputs=$(this).parents('.step').find('input[required]'); $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border'); $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border'); for (var i=0; i < required_inputs.length; i++){ switch(required_inputs.eq(i).attr('type')){ case "checkbox": { if(required_inputs.eq(i).prop('checked')===false){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } case "email": { if(!(emailValivatePattern.test(required_inputs.eq(i).val()))){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } case "tel": { if(!validatePhoneNumber(required_inputs.eq(i).get(0))){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; } default:{ if(required_inputs.eq(i).val()==='' && required_inputs.eq(i).attr('type')!=='hidden'){ required_inputs.eq(i).addClass('ays_red_border'); required_inputs.eq(i).addClass('shake'); empty_inputs++; }else{ required_inputs.eq(i).addClass('ays_green_border'); } break; }} } var empty_inputs2=0; var phoneInput=$(this).parents('.step').find('input[name="ays_user_phone"]'); var emailInput=$(this).parents('.step').find('input[name="ays_user_email"]'); var selectAttr=$(this).parents('.step').find('select.ays_quiz_form_input[required]'); if(phoneInput.val()!=''){ phoneInput.removeClass('ays_red_border'); phoneInput.removeClass('ays_green_border'); if(!validatePhoneNumber(phoneInput.get(0))){ if(phoneInput.attr('type')!=='hidden'){ phoneInput.addClass('ays_red_border'); phoneInput.addClass('shake'); empty_inputs2++; }}else{ phoneInput.addClass('ays_green_border'); }} if(emailInput.val()!=''){ emailInput.removeClass('ays_red_border'); emailInput.removeClass('ays_green_border'); if(!(emailValivatePattern.test(emailInput.val()))){ if(emailInput.attr('type')!=='hidden'){ emailInput.addClass('ays_red_border'); emailInput.addClass('shake'); empty_inputs++; }}else{ emailInput.addClass('ays_green_border'); }} if(selectAttr.val()==''){ selectAttr.removeClass('ays_red_border'); selectAttr.removeClass('ays_green_border'); selectAttr.addClass('ays_red_border'); selectAttr.addClass('shake'); empty_inputs++; }else{ selectAttr.removeClass('ays_red_border'); } var errorFields=$(this).parents('.step').find('.ays_red_border'); if(empty_inputs2!==0||empty_inputs!==0){ setTimeout(function(){ errorFields.each(function(){ $(this).removeClass('shake'); }); }, 500); setTimeout(function(){ required_inputs.each(function(){ $(this).removeClass('shake'); }); }, 500); return false; }else{ $(this).addClass('ays_start_allow'); }}else{ if($(this).parents('.step').find('.information_form').length!==0){ var empty_inputs=0; var phoneInput=$(this).parents('.step').find('input[name="ays_user_phone"]'); var emailInput=$(this).parents('.step').find('input[name="ays_user_email"]'); var emailInputs=$(this).parents('.step').find('input[type="email"]'); if(phoneInput.val()!=''){ phoneInput.removeClass('ays_red_border'); phoneInput.removeClass('ays_green_border'); if(!validatePhoneNumber(phoneInput.get(0))){ if(phoneInput.attr('type')!=='hidden'){ phoneInput.addClass('ays_red_border'); phoneInput.addClass('shake'); empty_inputs++; }}else{ phoneInput.addClass('ays_green_border'); }} if(emailInput.val()!=''){ emailInput.removeClass('ays_red_border'); emailInput.removeClass('ays_green_border'); if(!(emailValivatePattern.test(emailInput.val()))){ if(emailInput.attr('type')!=='hidden'){ emailInput.addClass('ays_red_border'); emailInput.addClass('shake'); empty_inputs++; }}else{ emailInput.addClass('ays_green_border'); }} emailInputs.each(function(){ var thisEmailInput=$(this); if(thisEmailInput.val()!=''){ thisEmailInput.removeClass('ays_red_border'); thisEmailInput.removeClass('ays_green_border'); if(!(emailValivatePattern.test(thisEmailInput.val()))){ thisEmailInput.addClass('ays_red_border'); thisEmailInput.addClass('shake'); empty_inputs++; }else{ thisEmailInput.addClass('ays_green_border'); }} }); var errorFields=$(this).parents('.step').find('.ays_red_border'); if(empty_inputs!==0){ setTimeout(function(){ errorFields.each(function(){ $(this).removeClass('shake'); }); }, 500); return false; } $(this).addClass('ays_start_allow'); }} } if(animating) return false; animating=true; current_fs=$(this).parents('.step'); next_fs=$(this).parents('.step').next(); var questions_count=$(this).parents('form').find('div[data-question-id]').length; var curent_number=$(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; var next_sibilings_count=$(this).parents('form').find('.ays_question_count_per_page').val(); if(parseInt(next_sibilings_count)>0&&($(this).parents('.step').attr('data-question-id')||$(this).parents('.step').next().attr('data-question-id'))){ if(parseInt(next_sibilings_count) >=questions_count){ next_sibilings_count=questions_count; } var current_fs_index=$(this).parents('form').find('.step').index($(this).parents('.step')); if($(this).parents('.step').attr('data-question-id')){ current_fs=$(this).parents('form').find('.step').slice(current_fs_index-parseInt(next_sibilings_count),current_fs_index+1); }else{ current_fs=$(this).parents('.step'); } if(questions_count===curent_number){ if(current_fs.hasClass('.information_form').length!==0){ current_fs.find('.ays_next').eq(current_fs.find('.ays_next').length-1).addClass('ays_timer_end'); current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500); }} if(curent_number!=questions_count){ if(($(this).hasClass('ays_finish'))==false){ if(!($(this).hasClass('start_button'))){ var count_per_page=Math.floor(questions_count/parseInt(next_sibilings_count)); var nextCountQuestionsPerPage=questions_count-curent_number; var current_width=$(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); var final_width=((curent_number+parseInt(next_sibilings_count)) / questions_count * 100) + "%"; if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){ final_width=((curent_number+nextCountQuestionsPerPage) / questions_count * 100) + "%"; } if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(nextCountQuestionsPerPage))); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(next_sibilings_count))); }}else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); }} }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); },300) } var next_siblings=$(this).parents('.step').nextAll('.step').slice(0,parseInt(next_sibilings_count)); if($(this).parents('form').find('div[data-question-id]').index($(this).parents('.step'))+1!==$(this).parents('form').find('div[data-question-id]').length){ for (var z=0; z < next_siblings.length; z++){ if(next_siblings.eq(z).attr('data-question-id')===undefined){ next_siblings.splice(z); }} }else{ if(next_siblings.length!==1){ next_siblings.splice(next_siblings.length - 1); }} $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); for(var i=0 ;i 0){ if(next_siblings.find('.ays-text-field').width() < 250){ next_siblings.find('.ays-text-field').css({ 'flex-wrap': 'wrap', 'justify-content': 'center', 'padding': '5px' }); next_siblings.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px'); }} },2000); }else{ current_fs=$(this).parents('.step'); next_fs=$(this).parents('.step').next(); var questions_count=$(this).parents('form').find('div[data-question-id]').length; var curent_number=$(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))+1; if(questions_count===curent_number){ if(current_fs.hasClass('.information_form').length!==0){ current_fs.find('.ays_next').addClass('ays_timer_end'); current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500); }} if(curent_number!=questions_count){ if(($(this).hasClass('ays_finish'))==false){ if(!($(this).hasClass('start_button'))){ var current_width=$(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); var final_width=((curent_number+1) / questions_count * 100) + "%"; if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); }} }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); },300) } $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); if(current_fs.hasClass('ays-abs-fs')){ current_fs=$(this).parents('.step'); next_fs=$(this).parents('.step').next(); var counterClass=""; switch(ays_quiz_container.data('questEffect')){ case "shake": counterClass=ays_quiz_container.data('questEffect'); break; case "fade": counterClass="fadeIn"; break; case "none": counterClass=""; break; default: counterClass=ays_quiz_container.data('questEffect'); break; } next_fs.find('.ays-question-counter').addClass(counterClass); } current_fs.removeClass('active-step'); next_fs.addClass('active-step'); var nextQuestionType=next_fs.find('input[name^="ays_questions"]').attr('type'); var buttonsDiv=next_fs.find('.ays_buttons_div'); var enableArrows=$(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); if(myOptions.enable_arrows){ enableArrows=myOptions.enable_arrows=='on' ? true:false; }else{ enableArrows=parseInt(enableArrows)==1 ? true:false; } var nextArrowIsDisabled=buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none'); var nextButtonIsDisabled=buttonsDiv.find('input.ays_next').hasClass('ays_display_none'); if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text'&&nextArrowIsDisabled&&nextButtonIsDisabled){ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); } if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text'&&enableArrows){ buttonsDiv.find('input.ays_next').addClass('ays_display_none'); buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); } if(nextQuestionType==='checkbox'&&nextArrowIsDisabled&&nextButtonIsDisabled){ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); } if(nextQuestionType==='checkbox'&&enableArrows){ buttonsDiv.find('input.ays_next').addClass('ays_display_none'); buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); } if(nextQuestionType==='number'&&nextArrowIsDisabled&&nextButtonIsDisabled){ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); } if(nextQuestionType==='number'&&enableArrows){ buttonsDiv.find('input.ays_next').addClass('ays_display_none'); buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); } if(nextQuestionType==='text'&&nextArrowIsDisabled&&nextButtonIsDisabled){ next_fs.find('.ays_buttons_div').find('input.ays_next').removeClass('ays_display_none'); } if(nextQuestionType==='text'&&enableArrows){ next_fs.find('.ays_buttons_div').find('input.ays_next').addClass('ays_display_none'); next_fs.find('.ays_buttons_div').find('i.ays_next_arrow').removeClass('ays_display_none'); } if(nextQuestionType==='date'&&nextArrowIsDisabled&&nextButtonIsDisabled){ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); } if(nextQuestionType==='date'&&enableArrows){ buttonsDiv.find('input.ays_next').addClass('ays_display_none'); buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none'); } var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; var checkUserAnswered=false; if(next_fs.find('.ays-quiz-answers .ays-field textarea').length){ nextQuestionType='text'; } if(next_fs.find('.ays-quiz-answers .ays-field select.ays-select').length){ nextQuestionType='select'; } if(next_fs.hasClass('ays-custom-step')){ nextQuestionType='custom'; } switch (nextQuestionType){ case "radio": checkUserAnswered=next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked'); break; case "checkbox": checkUserAnswered=next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked'); break; case "number": var questionTypeVal=next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length; if(questionTypeVal!==0){ checkUserAnswered=true; } break; case "text": var questionTypeVal=next_fs.find('.ays-quiz-answers .ays-field textarea, .ays-quiz-answers .ays-field input[type="text"]').val(); if(questionTypeVal!==''){ checkUserAnswered=true; } break; case "date": var questionTypeVal=next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length; if(questionTypeVal!==0){ checkUserAnswered=true; } break; case "select": var questionTypeEl=next_fs.find('.ays-quiz-answers .ays-field select.ays-select option[data-chisht]'); questionTypeEl.each(function(){ var questionTypeVal=$(this).attr('selected'); if(questionTypeVal){ checkUserAnswered=true; }}); break; case "custom": checkUserAnswered=true; break; default: checkUserAnswered=next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').prop('ckecked'); break; } if(isRequiredQuestion===true){ if(next_fs.find('.information_form').length===0){ if(enableArrows){ if(! checkUserAnswered){ buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled'); }else{ if(nextQuestionType=='custom'){ buttonsDiv.find('i.ays_next').removeAttr('disabled'); buttonsDiv.find('i.ays_finish').removeAttr('disabled'); } buttonsDiv.find('i.ays_early_finish').removeAttr('disabled'); }}else{ if(! checkUserAnswered){ buttonsDiv.find('input.ays_next').attr('disabled', 'disabled'); }else{ if(nextQuestionType=='custom'){ buttonsDiv.find('input.ays_next').removeAttr('disabled'); buttonsDiv.find('input.ays_finish').removeAttr('disabled'); } buttonsDiv.find('input.ays_early_finish').removeAttr('disabled'); }} }} aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); next_fs.find('.ays-text-input').trigger("focus"); setTimeout(function(){ if(next_fs.find('.ays-text-field').length > 0){ if(next_fs.find('.ays-text-field').width() < 250){ next_fs.find('.ays-text-field').css({ 'flex-wrap': 'wrap', 'justify-content': 'center', 'padding': '5px' }); next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px'); }} },2000); } if($(document).scrollTop() >=$(this).parents('.ays-questions-container').offset().top||$(this).parents('.ays-questions-container').offset().top > 500){ ays_quiz_container.goTo(); } if(current_fs.find('audio').length > 0){ current_fs.find('audio').each(function(e, el){ el.pause(); }); } if(current_fs.find('video').length > 0){ current_fs.find('video').each(function(e, el){ el.pause(); }); } if(current_fs.find('audio').length > 0){ var sound_src=next_fs.find('audio').attr('src'); if(typeof sound_src!=='undefined'){ var audio=next_fs.find('audio').get(0); audio.pause(); audio.currentTime=0; }} var enableAudioAutoplay=(myOptions.enable_audio_autoplay&&myOptions.enable_audio_autoplay=='on') ? true:false; if(next_fs.find('audio').length > 0){ if(enableAudioAutoplay){ var sound_src=next_fs.find('audio').attr('src'); if(typeof sound_src!=='undefined'){ var audio=next_fs.find('audio').get(0); audio.currentTime=0; audio.play(); }} } var enableNextButton=(myOptions.enable_next_button&&myOptions.enable_next_button=='off') ? true:false; var enableArrows=(myOptions.enable_arrows&&myOptions.enable_arrows=='on') ? true:false; if(enableNextButton){ if(next_fs.hasClass('ays-custom-step')){ if(enableArrows){ next_fs.find('.ays_buttons_div i.ays_next.action-button.ays_arrow').removeClass('ays_display_none'); }else{ next_fs.find('.ays_buttons_div input.ays_next.action-button').removeClass('ays_display_none'); }} }}); $(document).find('.ays_previous').on("click", function(e){ ays_quiz_container=$(this).parents(".ays-quiz-container"); var enableArrows=ays_quiz_container.find(".ays-questions-container .ays_qm_enable_arrows").val(); if(myOptions.enable_arrows){ enableArrows=myOptions.enable_arrows=='on' ? true:false; }else{ enableArrows=parseInt(enableArrows)==1 ? true:false; } if(typeof explanationTimeout!='undefined'){ clearTimeout(explanationTimeout); var thisButtonsDiv=$(this).parents(".ays_buttons_div"); setTimeout(function(){ if(thisButtonsDiv.find('input.ays_next').hasClass('ays_display_none') && thisButtonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')){ if(enableArrows){ thisButtonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); }else{ thisButtonsDiv.find('input.ays_next').removeClass('ays_display_none'); }} }, 1000); } if(animating) return false; animating=true; var next_sibilings_count=ays_quiz_container.find('.ays_question_count_per_page').val(); if(parseInt(next_sibilings_count)>0&&($(this).parents('.step').attr('data-question-id')||$(this).parents('.step').next().attr('data-question-id'))){ var questions_count=ays_quiz_container.find('div[data-question-id]').length; var curent_number_of_this=ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1; var curent_number=ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - parseInt(next_sibilings_count) + 1; var count_per_page=questions_count%parseInt(next_sibilings_count); var nextCountQuestionsPerPage=questions_count-curent_number; if(count_per_page > 0&&curent_number_of_this==questions_count){ curent_number=ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - count_per_page + 1; } if(!($(this).hasClass('start_button'))){ var current_width=$(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); var final_width=((curent_number) / questions_count * 100) + "%"; if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number)); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); } var current_fs_index=ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0)); if($(this).parents('.step').attr('data-question-id')){ current_fs=ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(next_sibilings_count)); }else{ current_fs=$(this).parents('.step'); } var current_first_fs_index=ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0)); var next_fs=ays_quiz_container.find('div[data-question-id]').slice((current_first_fs_index - parseInt(next_sibilings_count)), current_first_fs_index); var buttonsDiv=next_fs.find('.ays_buttons_div'); var enableArrows=$(document).find(".ays-questions-container .ays_qm_enable_arrows").val(); if(myOptions.enable_arrows){ enableArrows=myOptions.enable_arrows=='on' ? true:false; }else{ enableArrows=parseInt(enableArrows)==1 ? true:false; } if(buttonsDiv.find('input.ays_next').hasClass('ays_display_none') && buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')){ if(enableArrows){ buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); }else{ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); }} ays_quiz_container.find('div[data-question-id]').eq(current_fs_index).removeClass('active-step'); next_fs.eq(0).addClass('active-step') if($(this).parents('form').hasClass('enable_correction')){ if(next_fs.find('.correct').length!==0||$(this).parents('div[data-question-id]').prev().find('.wrong').length!==0){ next_fs.find('input[name^="ays_questions"]').on('click',function (){ return false; }); }} $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); next_fs.find('.ays-text-input').trigger("focus"); }else{ if($(this).parents('form').hasClass('enable_correction')){ if($(this).parents('div[data-question-id]').prev().find('.correct').length!==0||$(this).parents('div[data-question-id]').prev().find('.wrong').length!==0){ $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').on('click',function (){ return false; }); }} current_fs=$(this).parents('.step'); next_fs=$(this).parents('.step').prev(); var buttonsDiv=next_fs.find('.ays_buttons_div'); if(buttonsDiv.find('input.ays_next').hasClass('ays_display_none') && buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')){ if(enableArrows){ buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none'); buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled'); buttonsDiv.find('i.ays_early_finish').removeAttr('disabled'); buttonsDiv.find('i.ays_next_arrow').removeProp('disabled'); buttonsDiv.find('i.ays_early_finish').removeProp('disabled'); }else{ buttonsDiv.find('input.ays_next').removeClass('ays_display_none'); buttonsDiv.find('input.ays_next').removeAttr('disabled'); buttonsDiv.find('input.ays_early_finish').removeAttr('disabled'); buttonsDiv.find('input.ays_next').removeProp('disabled'); buttonsDiv.find('input.ays_early_finish').removeProp('disabled'); }} $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false); if(current_fs.hasClass('ays-abs-fs')){ current_fs=$(this).parents('.step'); next_fs=$(this).parents('.step').prev(); var counterClass=""; switch(ays_quiz_container.data('questEffect')){ case "shake": counterClass=ays_quiz_container.data('questEffect'); break; case "fade": counterClass="fadeIn"; break; case "none": counterClass=""; break; default: counterClass=ays_quiz_container.data('questEffect'); break; } next_fs.find('.ays-question-counter').addClass(counterClass); } current_fs.removeClass('active-step'); next_fs.addClass('active-step'); var questions_count=$(this).parents('form').find('div[data-question-id]').length; var curent_number=$(this).parents('form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))-1; if(curent_number!=questions_count){ if(($(this).hasClass('ays_finish'))==false){ if(!($(this).hasClass('start_button'))){ var current_width=$(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width(); var final_width=((curent_number+1) / questions_count * 100) + "%"; if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1)); }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width)); } $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000); }} }else{ $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); },300) } aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs); next_fs.find('.ays-text-input').trigger("focus"); } if($(document).scrollTop() >=$(this).parents('.ays-questions-container').offset().top||$(this).parents('.ays-questions-container').offset().top > 500){ ays_quiz_container.goTo(); } if(current_fs.find('audio').length > 0){ current_fs.find('audio').each(function(e, el){ el.pause(); }); } if(current_fs.find('video').length > 0){ current_fs.find('video').each(function(e, el){ el.pause(); }); } if(current_fs.find('audio').length > 0){ var sound_src=next_fs.find('audio').attr('src'); if(typeof sound_src!=='undefined'){ var audio=next_fs.find('audio').get(0); audio.pause(); audio.currentTime=0; }} var enableAudioAutoplay=(myOptions.enable_audio_autoplay&&myOptions.enable_audio_autoplay=='on') ? true:false; if(next_fs.find('audio').length > 0){ if(enableAudioAutoplay){ var sound_src=next_fs.find('audio').attr('src'); if(typeof sound_src!=='undefined'){ var audio=next_fs.find('audio').get(0); audio.currentTime=0; audio.play(); }} }}); $(document).find('.ays-quiz-container input').on('focus',function (){ $(window).on('keydown',function (event){ if(event.keyCode===13){ return false; }}); }); $(document).find('.ays-quiz-container input').on('blur',function (){ $(window).off('keydown'); }); $(document).on('click', '.ays-quiz-container .ays_question_hint', function (e){ $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').toggleClass('z_index_0'); $(e.target).parent().find('.ays_question_hint_text').toggleClass('show_hint'); if($(e.target).parent().find('.ays_question_hint_text').hasClass('show_hint')){ $(window).on('click', function(ev){ if(!($(ev.target).hasClass('ays_question_hint_text')||$(ev.target).hasClass('ays_question_hint'))){ $(e.target).parent().find('.ays_question_hint_text').removeClass('show_hint') $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').removeClass('z_index_0'); }}); }}); $(document).on('click', '.ays-field', function(){ if($(this).find(".select2").hasClass('select2-container--open')){ $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_down'); $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_up'); }else{ $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_up'); $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); }}); $(document).find('select.ays-select').on("select2:selecting", function(e){ $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); }); $(document).find('select.ays-select').on("select2:closing", function(e){ $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); }); $(document).find('select.ays-select').on("select2:select", function(e){ var quizContainer=$(e.target).parents('.ays-quiz-container'); var right_answer_sound=quizContainer.find('.ays_quiz_right_ans_sound').get(0); var wrong_answer_sound=quizContainer.find('.ays_quiz_wrong_ans_sound').get(0); var finishAfterWrongAnswer=(myOptions.finish_after_wrong_answer&&myOptions.finish_after_wrong_answer=="on") ? true:false; var showOnlyWrongAnswer=(myOptions.show_only_wrong_answer&&myOptions.show_only_wrong_answer=="on") ? true:false; var explanationTime=myOptions.explanation_time&&myOptions.explanation_time!="" ? parseInt(myOptions.explanation_time):4; $(this).parent().find('.ays-select-field-value').attr("value", $(this).val()); if($(this).parents(".ays-questions-container").find('form[id^="ays_finish_quiz"]').hasClass('enable_correction')){ var chishtPatasxan=$(this).find('option:selected').data("chisht"); if(chishtPatasxan==1){ if((right_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ right_answer_sound.play(); }, 10); } $(this).parents('.ays-field').addClass('correct_div checked_answer_div'); $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(0, 128, 0, 0.6)"); }else{ if((wrong_answer_sound)){ resetPlaying([right_answer_sound, wrong_answer_sound]); setTimeout(function(){ wrong_answer_sound.play(); }, 10); } $(this).parents('.ays-field').addClass('wrong_div checked_answer_div'); $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(255, 2, 2, 0.6)"); if(showOnlyWrongAnswer===false){ var rightAnswerText='
'+ $(this).find('option[data-chisht="1"]').html()+ '
'; $(this).parents('.ays-quiz-answers').append(rightAnswerText); $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').css("text-align", "left"); $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500); }} if(myOptions.answers_rw_texts&&(myOptions.answers_rw_texts=='on_passing'||myOptions.answers_rw_texts=='on_both')){ if(chishtPatasxan==1){ $(e.target).parents().eq(3).find('.right_answer_text').slideDown(500); }else{ $(e.target).parents().eq(3).find('.wrong_answer_text').slideDown(500); }} if(finishAfterWrongAnswer&&chishtPatasxan!=1){ $(e.target).parents('div[data-question-id]').find('.ays_next').attr('disabled', 'disabled'); $(e.target).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled'); } explanationTimeout=setTimeout(function(){ if(chishtPatasxan==1){ if($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click'); }}else{ if(finishAfterWrongAnswer){ goToLastPage(e); }else{ if($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click'); }} }}, explanationTime*1000); $(this).attr("disabled", true); }else{ if($(this).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && $(this).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(this).parents('div[data-question-id]').find('.ays_next').trigger('click'); }} var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(isRequiredQuestion===true){ if($(this).find('option:selected').length!=0){ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled'); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled'); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled'); }}else{ if(!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true); }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true); $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true); }} } var this_select_value=$(this).val(); $(this).find("option").removeAttr("selected"); $(this).find("option[value='"+this_select_value+"']").attr("selected", true); }); function aysSelectDropdownCheck(select){ var isRequiredQuestion=(myOptions.make_questions_required&&myOptions.make_questions_required=="on") ? true:false; if(isRequiredQuestion===true){ if(select.val()!=''){ if(!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ select.parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled'); select.parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled'); }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ select.parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled'); select.parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled'); }}else{ if(!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){ select.parents('div[data-question-id]').find('input.ays_next').attr('disabled', true); select.parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true); }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')){ select.parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true); select.parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true); }} }} var shareButtons=document.querySelectorAll(".ays-share-btn.ays-to-share"); if(shareButtons){ [].forEach.call(shareButtons, function(button){ button.addEventListener("click", function(event){ var width=650, height=450; event.preventDefault(); window.open(this.href, quizLangObj.shareDialog, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+(screen.height/2-height/2)+',left='+(screen.width/2-width/2)); }); }); } $(document).find('.ays-quiz-container').map(function (){ $(this).find('div[data-question-id]').eq(0).find('.ays_previous').css({'display':'none'}); var next_sibilings_count=parseInt($(this).find('.ays_question_count_per_page').val()); if(next_sibilings_count>0){ $(this).find('div[data-question-id]').eq(next_sibilings_count-1).find('.ays_previous').css({'display':'none'}); }}); $(document).find('.ays_finish.action-button.ays_arrow').on('click', function (){ $(this).parents('.ays_buttons_div').find('input.ays_next.action-button').trigger('click'); }); $(document).find('div[data-question-id]').map(function (){ $(this).find('.ays-quiz-answers .ays-field').map(function (){ if($(this).find('label[for^="ays-answer"]').eq(1).find('img').length!==0){ $(this).find('label[for^="ays-answer"]').eq(0).addClass('ays_empty_before_content'); if($(this).find('label[for^="ays-answer"]').eq(0).text().length===0){ $(this).find('label[for^="ays-answer"]').eq(0).css('background','transparent'); }} }); }); $(document).find('.ays_finish.action-button').on('click', function (){ $(this).addClass("ays_timer_end"); if(typeof $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page")!=='undefined'){ if(! $(this).parents('.ays-quiz-container').find('.step.active-step .ays-abs-fs.ays-end-page').hasClass('information_form')){ $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false); }} }); $(document).on('click', '.ays_early_finish.action-button', function (e){ e.preventDefault(); if(typeof $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page")!=='undefined'){ if(! $(this).parents('.ays-quiz-container').find('.step .ays-abs-fs.ays-end-page').hasClass('information_form')){ $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false); }} var confirm; if(myOptions.enable_early_finsh_comfirm_box&&myOptions.enable_early_finsh_comfirm_box=="off"){ confirm=true; }else{ confirm=window.confirm(quizLangObj.areYouSure); } if(confirm){ clearTimeout(explanationTimeout); var totalSteps=$(e.target).parents().eq(3).find('div.step').length; var currentStep=$(e.target).parents().eq(3).find('div.step.active-step'); var thankYouStep=$(e.target).parents().eq(3).find('div.step.ays_thank_you_fs'); var infoFormLast=thankYouStep.prev().find('div.information_form'); var questions_count=$(e.target).parents('form').find('div[data-question-id]').length; $(this).parents('.ays-quiz-container').find('.ays_finish.action-button').addClass("ays_timer_end"); if($(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(questions_count); }else{ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({ width: '100%' }); $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(100); } currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(); setTimeout(function (){ currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); },300); if(infoFormLast.length==0){ if(currentStep.hasClass('ays_thank_you_fs')===false){ var steps=totalSteps - 3; $(e.target).parents().eq(3).find('div.step').each(function (index){ if($(this).hasClass('ays_thank_you_fs')){ $(this).addClass('active-step') }else{ $(this).css('display', 'none'); }}); $(e.target).parents().eq(3).find('input.ays_finish').trigger('click'); }}else{ currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide(); $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none'); },300); aysAnimateStep($(e.target).parents('.ays-quiz-container').data('quest-effect'), currentStep, infoFormLast.parent()); $(e.target).parents().eq(3).find('div.step').each(function (index){ $(this).css('display', 'none'); $(this).removeClass('active-step') }); infoFormLast.parent().css('display', 'flex'); infoFormLast.parent().addClass('active-step'); $(this).parents(".ays-quiz-container").find('.ays_finish.action-button').addClass("ays_timer_end"); } if($(document).scrollTop() >=$(this).parents('.ays-questions-container').offset().top||$(this).parents('.ays-questions-container').offset().top > 500){ $(this).parents(".ays-quiz-container").goTo(); }} }); $(document).find('.action-button.ays_restart_button').on('click', function (){ window.location.reload(); }); $(document).on('click', '.action-button.ays_clear_answer', function (){ var $this=$(this); var activeStep=$this.parents('.step'); var inputs=activeStep.find('input[name^="ays_questions[ays-question-"]:checked'); var checked_answer_divs=activeStep.find('div.ays-field.checked_answer_div'); var ays_text_field=activeStep.find('div.ays-field.ays-text-field'); var ays_select_field=activeStep.find('div.ays-field.ays-select-field'); inputs.removeAttr('checked'); inputs.trigger('change'); checked_answer_divs.removeClass('checked_answer_div'); ays_text_field.find('.ays-text-input').val(''); ays_text_field.find('.ays-text-input').trigger('input'); if(ays_select_field.find('select.ays-select').length > 0){ ays_select_field.find('select.ays-select').val(null).trigger('change'); aysSelectDropdownCheck(ays_select_field.find('select.ays-select')); }}); $(document).on('click', '.ays_music_sound', function(){ var $this=$(this); var quizCoutainer=$this.parents('.ays-quiz-container'); var audioEls=$(document).find('.ays_quiz_music'); var soundEls=$(document).find('.ays_music_sound'); var audioEl=quizCoutainer.find('.ays_quiz_music').get(0); if($this.hasClass('ays_sound_active')){ audioEl.volume=0; $this.find('.ays_fa').addClass('ays_fa_volume_off').removeClass('ays_fa_volume_up'); $this.removeClass('ays_sound_active'); }else{ audioEl.volume=1; $this.find('.ays_fa').addClass('ays_fa_volume_up').removeClass('ays_fa_volume_off'); $this.addClass('ays_sound_active'); }}); function goToLastPage(e){ clearTimeout(explanationTimeout); var container=$(e.target).parents('.ays-quiz-container'); var totalSteps=container.find('div.step').length; var currentStep=container.find('div.step.active-step'); var thankYouStep=container.find('div.step.ays_thank_you_fs'); var infoFormLast=thankYouStep.prev().find('div.information_form'); var questions_count=$(e.target).parents('form').find('div[data-question-id]').length; if(container.find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){ container.find('.ays-live-bar-percent').text(questions_count); }else{ container.find('.ays-live-bar-fill').animate({ width: '100%' }); container.find('.ays-live-bar-percent').text(100); } container.find('.ays-quiz-timer').slideUp(); setTimeout(function (){ container.find('.ays-quiz-timer').parent().hide(); },300); if(infoFormLast.length==0){ if(currentStep.hasClass('ays_thank_you_fs')===false){ var steps=totalSteps - 3; container.find('div.step').each(function (index){ if($(this).hasClass('ays_thank_you_fs')){ $(this).addClass('active-step') }else{ $(this).css('display', 'none'); }}); container.find('input.ays_finish').trigger('click'); }}else{ container.find('.ays-quiz-timer').parent().hide(); container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut'); setTimeout(function (){ container.find('.ays-live-bar-wrap').css('display','none'); },300); aysAnimateStep(container.data('quest-effect'), currentStep, infoFormLast.parent()); container.find('div.step').each(function (index){ $(this).css('display', 'none'); $(this).removeClass('active-step') }); infoFormLast.parent().css('display', 'flex'); infoFormLast.parent().addClass('active-step'); }} function ays_formatState (ays_state){ if(!ays_state.id){ return aysEscapeHtml(ays_state.text); } var baseUrl=$(ays_state.element).data('nkar'); if(baseUrl!=''){ var ays_state=$( ' ' + aysEscapeHtml(ays_state.text) + '' ); }else{ var ays_state=$('' + aysEscapeHtml(ays_state.text) + ''); } return ays_state; } $(document).find('.ays-quiz-container').each(function(){ var $this=$(this); $this.find('select.ays-select').select2({ placeholder: quizLangObj.selectPlaceholder, dropdownParent: $this, templateResult: ays_formatState }); }); $(document).find('.ays-quiz-container b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down'); function aysResetQuiz ($quizContainer){ var cont=$quizContainer.find('div[data-question-id]'); cont.find('input[type="text"], textarea, input[type="number"], input[type="url"], input[type="email"]').each(function(){ $(this).val(''); }); cont.find('select').each(function(){ $(this).val(''); }); cont.find('select.ays-select').each(function(){ $(this).val(null).trigger('change'); }); cont.find('select option').each(function(){ $(this).removeAttr('selected'); }); cont.find('input[type="radio"], input[type="checkbox"]').each(function(){ $(this).removeAttr('checked'); }); } window.onbeforeunload=function (e){ var startButton=$(document).find('.ays-quiz-container .ays_next.start_button'); var flag=false; for (var i=0; i < startButton.length; i++){ var startBtn=startButton.eq(i).attr('data-enable-leave-page'); if(typeof startBtn!=undefined&&startBtn==='true'){ flag=true; break; }} if(flag){ return true; }else{ return null; }} var countDownEndDate=$(document).find('#show_timer_countdown').data('timer_countdown'); if(countDownEndDate!=''&&countDownEndDate!=undefined){ var showM=$(document).find('#show_timer_countdown').parents('.step').data('messageExist'); ays_countdown_datetime(countDownEndDate, !showM); }}); })(jQuery);